HaxeFoundation / HaxeFoundation/haxe
Can't call op(a()) from abstract imported via import alias (Haxe 5)
- Dominant language
- Haxe
- Stars
- 6.9k
- Forks
- 715
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 11
Description
This bug is oddly specific. It won't happen if Logger is a class rather than an abstract, it won't happen if I don't use an import alias for the field and it won't happen if the eval method is directly referenced rather than called via `@:op(a())`. This doesn't happen in haxe 4, only in haxe 5 preview and nightlies.
Test.hx
```hx
import Assert;
import Test.Logger.assert as gAssert;
class Test {
static function main() {
gAssert(5 > 4);
// gAssert.eval(5 > 4); // works
// Logger.assert(5 > 4); // works
}
}
@:forward
abstract Logger(LoggerRaw) from LoggerRaw {
static public final log:Logger = new LoggerRaw();
static public var assert(get, never):Assert;
static inline function get_assert():Assert
return log.error;
inline public function new()
this = new LoggerRaw();
}
class LoggerRaw {
public final error = new Assert();
public function new() {}
}
```
Assert.hx
```hx
import haxe.macro.Expr;
abstract Assert(Int) {
public function new()
this = 0;
@:op(a())
macro public function eval(expr:ExprOf, args:Array):Expr {
return macro trace(${args[0]});
}
}
```
For example, I tried the following and it worked:
```hx
class Logger {
static public final log:Logger = new LoggerRaw();
static public var assert(get, never):Assert;
static inline function get_assert():Assert
return log.error;
public final error = new Assert();
public function new() {}
}
```
Contributor guide
Assessment
This issue has not been assessed yet.