Hello.
I my project, for every script I load, I inject a global variable with it's own ID, like this:
scriptModule->AddScriptSection("abcd", fmt::format("const int thisScript = {};", unit_id).c_str());
However, without any modification to the C++ code (only to one included script), this variable started exhibiting a glitch - for every odd invocation of a script, it contains exactly the value from the previous run.
I debug-stepped into asCBuilder::CompileGlobalVariables() and saw that the value is set correctly. (Please ignore the values in the screenshots, they come from multiple tests).

However, when hitting a breakpoint in a function invoked by the script with thisScript as parameter, I see the old value. Same happens when I concat the value to string and log that.


On the master branch of my project, everything works OK. This is the outer script loading code: ScriptEngine.cpp#L835-L927 and this is where the global var is set up: ScriptEngine.cpp#L965
However, things break in PR 3395, specifically after this commit which only changes one include script: 5a5138f583c2e72aa505ca3a4abef95822f7e8fb, this is the offending line:174|179|dictionary@ scriptDetails = game.getScriptDetails(thisScript);. As commented in the PR, it was repeatedly reported by a tester using GitHub CI artifacts (comment link) and also happens to me running my own builds. In both cases AngelScript is obtained using Conan from ConanCenter: self.requires("angelscript/2.35.1")
I think I may have hit a bug in AngelScript, but it's difficult to isolate this case from the rest of the game (I don't know what exactly triggered it), so I'm posting this first and I'll continue investigating.
EDIT: Still happens with angelscript 2.38 (also conancenter).