Godot 3.1 - XYZ is declared but never used in the script - Oh my, how do I store vars now?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By The_Black_Chess_King

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,

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_love_godot | 2019-01-17 14:38

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
GDScript: warns that a class variable is unused while it actually is · Issue #23207 · godotengine/godot · GitHub

“The unused class variable warning appears even if variable used through autoload”
opened by Chaosus
The unused class variable warning appears even if variable used through autoload · Issue #22206 · godotengine/godot · GitHub

The_Black_Chess_King | 2019-01-17 14:41

@I_love_godot 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.

The_Black_Chess_King | 2019-01-17 14:43

:bust_in_silhouette: Reply From: RazorSh4rk

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.

:bust_in_silhouette: Reply From: wombatstampede

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.


… return_value_discarded


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


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

… 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):

aaforcebox | 2019-03-01 17:14

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

Kaligule | 2019-09-17 20:23

:bust_in_silhouette: Reply From: Dlean Jeans

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

Project Settings > General > Debug > Gdscript > Enable # Off

Yah but the problem with that is now Godot is telling what the errors are.

Merlin1846 | 2020-09-05 22:16