You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was wondering if anyone has some advice on an issue I'm facing.
It seems like in certain cases hxcpp (and possibly other targets) outputs code where temporary variables share the same name within the same scope.
for example the following works without issue:
class ScopeTest {
public function new(){
var a:Array<Dynamic> = [];
a.map(function(i:Dynamic):Dynamic{
trace("test1");
return i;
});
a.map(function(i:Dynamic):Dynamic{
trace("test2");
return i;
});
}
}
of interest is int _g = 0; and int _g2 = 0;
However the issue arises when one of the map calls is nested within another block, but in the same function.
for example:
class ScopeTest {
public function new(){
var a:Array<Dynamic> = [];
var i = 5;
while (i > 0){
a.map(function(i:Dynamic):Dynamic{
trace("test1");
return i;
});
i--;
}
a.map(function(i:Dynamic):Dynamic{
trace("test2");
return i;
});
}
}
This will generate cpp that defines int _g = ... twice:
In some scenarios this most likely isn't an issue, as haxe probably handles this, or if you're using -D no-compilation you can probably easy the strictness of these types of check.
However in my case I'm using -D no-compilation and don't have this kind of control. (compiling through unreal build tool)
This results in errors along the line of:
declaration of '_g' hides previous local declaration
It's also worth mentioning if I was writing something from scratch I'd simply avoid this pattern, however I'm porting a fairly large Haxe library that was originally intended for a different target and it has this issue all over the place.
My gut feeling is the compiler is most likely like this because it's a tricky problem to solve, but figured I'd ask here to see if anyone has any ideas
The text was updated successfully, but these errors were encountered:
Actually, looks like there is a work around in my case.
For anyone that is interested, Unreal uses {Module}.build.cs files to config each module.. within this file the following property can be set to: bEnableShadowVariableWarnings = false;
I don't really understand our renaming logic here and why that while makes any difference, but it looks like the C++ target has the wrong scope setting regardless.
Hey there
I was wondering if anyone has some advice on an issue I'm facing.
It seems like in certain cases hxcpp (and possibly other targets) outputs code where temporary variables share the same name within the same scope.
for example the following works without issue:
this will generate cpp along the lines of:
of interest is
int _g = 0;
andint _g2 = 0;
However the issue arises when one of the map calls is nested within another block, but in the same function.
for example:
This will generate cpp that defines
int _g = ...
twice:In some scenarios this most likely isn't an issue, as haxe probably handles this, or if you're using
-D no-compilation
you can probably easy the strictness of these types of check.However in my case I'm using
-D no-compilation
and don't have this kind of control. (compiling through unreal build tool)This results in errors along the line of:
declaration of '_g' hides previous local declaration
It's also worth mentioning if I was writing something from scratch I'd simply avoid this pattern, however I'm porting a fairly large Haxe library that was originally intended for a different target and it has this issue all over the place.
My gut feeling is the compiler is most likely like this because it's a tricky problem to solve, but figured I'd ask here to see if anyone has any ideas
The text was updated successfully, but these errors were encountered: