Godot: For loop (with range) is always generate unused variable warning

Created on 17 Aug 2018  路  6Comments  路  Source: godotengine/godot

Godot version:
68676c7

Issue description:
IMO "for" loops should not spawn this warning to log, because its often used just for iteration and temp value can be not used at all

image

archived gdscript

Most helpful comment

Maybe we can allow _ as a loop variable if you know you won't need it

All 6 comments

Interestingly, for i in 2: doesn't raise the warning.

Maybe we can allow _ as a loop variable if you know you won't need it

While trying to clean the logs, hunting for real problems, I find two annoying ones.

One of them is the above. I even naturally tried _ hoping it will work.
The other one is integer division. No matter what I do or cast it keeps showing,
@karroffel suggestion is great +1 for that.
Additional option to silent warnings via settings or event better via code (to specific code blocks) will also help.

This workaround works like a charm!

for _i in range(MY_RANGE):

Thank you @okynos ,

Yes, I know this issue already solved in one of the 3.x releases.
I guess this issue is not relevant anymore.
OP ( @Chaosus ) should decide if he wishes to close it.

Yeah, its fixed, sorry for late react

Was this page helpful?
0 / 5 - 0 ratings