HaxeFoundation / HaxeFoundation/hashlink
Null exception when casting with inheritance of depth 2+
- Dominant language
- C
- Stars
- 901
- Forks
- 201
- Avg merge
- 18h 9m
- Merged PRs (30d)
- 8
Description
Casting a subclass of a subclass to their base class will cause a strange "null" exception at line 0 of a random external/standard library.
```haxe
abstract class A {
public abstract function work():Void;
}
abstract class B extends A {
public abstract function work(): Void;
}
class C extends B {
public function new() {}
public function work():Void {
trace("doing");
}
}
class Main {
static function main(){
var c = new C();
var a: A = cast c;
a.work();
}
}
```
Result:
Called from A.work(C:\HaxeToolkit\haxe\std/hl/_std/Date.hx:0)
Called from $Main.main(Main.hx:24)
Called from .init(?:1)
As you can see it strangely fails at "Date.hx:0". Casting to Dynamic instead can be used as a workaround.
The above code snippet works in other targets.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.