HaxeFoundation / haxe

Haxe - The Cross-Platform Toolkit
https://haxe.org
6.15k stars 656 forks source link

[python] Runtime error upon accessing non-existent field of anonymous object inferred from Dynamic #8105

Closed RealyUniqueName closed 5 years ago

RealyUniqueName commented 5 years ago
class Main {
    static function main() {

        var instance:Dynamic = {};
        trace(instance.field); //ok

        trace(({}:Dynamic).timeout); //ok

        var instance = ({}:Dynamic);
        trace(instance.field); //runtime error
    }
}
$ haxe -main Main -python test.py && python3 test.py
None
None
Traceback (most recent call last):
  File "bin/test.py", line 741, in <module>
    Main.main()
  File "bin/test.py", line 46, in main
    print(str(_hx_AnonObject({}).field))
AttributeError: '_hx_AnonObject' object has no attribute 'field'
Gama11 commented 5 years ago

Same as https://github.com/HaxeFoundation/haxe/issues/5051?

RealyUniqueName commented 5 years ago

Duplicates #7546

RealyUniqueName commented 5 years ago

Same as #5051?

No. That one was about properly typed var. This one is about inerred Dynamic.