HaxeFoundation / HaxeFoundation/haxe
@:from implicit cast does not work when casting from enum with parameter
- Dominant language
- Haxe
- Stars
- 6.9k
- Forks
- 715
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 11
Description
Here is the code that fails
Fails with Haxe 4.0.0-preview.5+f18f92c.
Does not fail with at least Haxe 4.0.0 (git build master @ 2344f23 (preview.1) and earlier.
```haxe
abstract Foo(String) {
@:from static public inline function from(bar: Bar):Foo {
return cast bar.getName();
}
}
enum Bar {
A(v: Int);
B;
}
class Test {
static function main() {
var foo: Foo = Bar.A(200); // compilation error: Bar should be Foo
}
}
```
BTW this code works as expected
```haxe
var bar: Bar = Bar.A(100);
var foo: Foo = bar;
```
This also works
```haxe
var foo: Foo = Bar.B;
```
Contributor guide
Assessment
This issue has not been assessed yet.