HaxeFoundation / HaxeFoundation/haxe

`@:from macro` does not allow implicit casting from abstracts.

Open
#6,595 2 comments 1 reaction 1 assignee Claimed by @Simn View on GitHub
platform-macro
Dominant language
Haxe
Stars
6.9k
Forks
715
Avg merge
2d 2h
Merged PRs (30d)
11

Description

```haxe
import haxe.macro.Expr;
import haxe.macro.Context;

class Test {
static function main() {
print("Hello"); // works fine

var val:MyString = "Hello";
print(val); // Error: MyString should be Message
}

static function print(msg:Message) {
trace(msg);
}
}

abstract MyString(String) from String to String {}

abstract Message(Dynamic) from Dynamic {
@:from macro static function from(value:ExprOf):ExprOf {
return macro Std.string($value);
}
}
```
http://try-haxe.mrcdk.com/#0A63B

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.