Error: Can't declare var statement in inline function
-
After the last commits, I get the below error in my project. It was working before. (The latest working version was built on the 6th September)
Can't declare var statement in inline function
My code structure is like the below:
inline function myFunction() { if (......) { var myvariable1 = false; var myvariable2 = false; } }
-
@Steve-Mohican indeed this happened in the latest commit, but you shouldn't use vars in in-line functions. Use locals instead.
-
Yes this is deliberate. If you're not using
local
variables, they will spill to the outside scope with very unpredictable side effects.inline function whatHappensInsideThisFunctionStaysInsideThisFunction() { var secret = 90; } whatHappensInsideThisFunctionStaysInsideThisFunction(); Console.print(secret); // Ouch...
-
@Christoph-Hart @Matt_SF I'll fix this thank you.