-
-
Notifications
You must be signed in to change notification settings - Fork 646
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[flash] Bitwise compound assignment with Map<Int, Int> and UInt inside of a switch statement causes Unbound variable and Compiler failure: Failed to locate variable declaration #11248
Comments
Reduced a bit: class Main {
public static var BIT_A:UInt = 1;
public static var FLAG_1:Int = 0;
static final flags = [0 => 1010];
@:matchDebug
static function main() {
switch Std.int(Math.random()) {
case 0:
flags[FLAG_1] |= BIT_A;
}
}
} The problem already shows up in the matcher output:
Note how 1045 and 1046 both appear before their definition. I struggle to reproduce this without the weird Map/UInt interaction, so I'm not sure yet where the problem actually comes from. |
Possibly related class Main {
public static var BIT_A:UInt = 1;
public static var FLAG_1:Int = 0;
static final _flags:Map<Int, Int> = [0 => 1010];
public static var flags(get, never):Map<Int, Int>;
public static function get_flags() {
return _flags;
}
static function main() {
flags[FLAG_1] ^= BIT_A;
}
}
|
I've isolated that example: abstract NotIntMap(String) {
@:arrayAccess public function get(key:Int)
return 1;
@:arrayAccess public function arrayWrite(k:Int, v:Int):Int {
return 1;
}
}
@:coreType
abstract NotUInt to Int from Int {
@:commutative @:op(A ^ B) private static function xorI(lhs:NotUInt, rhs:Int):NotUInt;
}
class Main {
public static var BIT_A:NotUInt = 1;
static final _flags:NotIntMap = null;
public static var flags(get, never):NotIntMap;
public static function get_flags() {
return _flags;
}
@:analyzer(full_debug)
static function main() {
flags[0] ^= BIT_A;
}
} The analyzer receives a use-before-def thing again:
Looks like some ordering issue in the operator handling code. |
@Simn should this be added to 4.3_bugfix? (maybe I should release a 4.3.x soon btw..) |
Did this fail on 4.2 already? If not then yes, otherwise no. |
Minimal example:
Compiler output
Tested on all targets except C#, only occurs for the Flash target
The text was updated successfully, but these errors were encountered: