+3 votes

Reference: Godot 3.1 Beta 1

Ported my project from 3.0 to 3.1 and bam, lots of errors, "Well let's start fixing them.", but the majority of the errors were:

"XYZ is declared but never used in the script."

Okay, so what do I do them? I commonly used this type of scripting:

onready var FutureItem = "" #Store a var type string for future use

And later, another object would access the first one, and change the var.

func Collision():
    OtherNode.FutureItem = "GRENADE"

I am having problems with my singletons, which creates a var, but in that script, it does not adds nothing to it, but other scripts access it and add values later on the game.

I am sure Godot is advancing, but I couldn't understand the reason for this to be considered an error,

It is a bad idea to store variables for future use?

Thanks in advance for any help you can bring me,

asked Jan 17, 2019 in Engine by The_Black_Chess_King (265 points)

I see messages like this sometimes. Are they actually errors, or just polite warnings? I don't think it's ever interfered with the running of a game. I always take them as a heads up, but nothing more than that.

I digged deeper into the issue and found some related problems, there are the links below for the GitHub discussions, for now my solution was to disable these types of "unused data" debugging errors, while I understood that is good for performance sake, It does not work with my workflow, for now.

(You can find the options for debugging check at -> Project settings -> General -> Debug -> Gdscript)

"GDScript: warns that a class variable is unused while it actually is"
opened by Zylann

"The unused class variable warning appears even if variable used through autoload"
opened by Chaosus

@Ilovegodot Well they show in the debug section like errors, but in my case it is growing project, and the errors bloated to more than 29, hiding and mixing with other errors in the debug window. Not good in my opinion. But yes, they don't break the functionality of the scripts.

3 Answers

+9 votes
Best answer

If you want leave the warnings enabled but make exceptions for certain declarations then you can prepend them with a special comment:

disable all warnings for the file:


ignore all warnings of type unused_variable in the file.


Ignore the next warning if it is of type unused_variable.


... unused class variable.


... returnvaluediscarded


... unused argument (sadly only works on the first unused argument if multiple)


I expect these comments to change or be expanded in the future.

answered Jan 18, 2019 by wombatstampede (3,185 points)
selected Feb 17, 2019 by The_Black_Chess_King

... unused argument (sadly only works on the first unused argument if

I had a function with 3 arguments, put the #warning comment 3 times before it and all warnings were ignored:

func supertest(arg1, arg2, arg3):

Since these strings are not documented anywhere (yet) here a link to the code where they are parsed: https://github.com/godotengine/godot/blob/24e1039eb6fe32115e8d1a62a84965e9be19a2ed/modules/gdscript/gdscript_tokenizer.cpp#L558

Valid comments for this are currently:

  • # warning-ignore:id_of_warning
  • # warning-ignore-all:id_of_warning
  • # warnings-disable
0 votes

If it really bothers you, you could

onready var my_little_var
func _ready():
    my_little_var = 10

But they are not errors, just warnings, the real problem is that you can't filter debugger messages by severity in the editor.

answered Jan 18, 2019 by RazorSh4rk (256 points)
+2 votes

Those are just warnings. What I did was simply turn them off.

Project Settings > General > Debug > Gdscript > Enable # Off
answered Jan 18, 2019 by Dlean Jeans (3,873 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.