HaxeFoundation / HaxeFoundation/haxe

[typer] regression with calling static @:to method statically

Open
#6,441 3 comments 0 reactions 1 assignee Claimed by @Simn View on GitHub
Dominant language
Haxe
Stars
6.9k
Forks
715
Avg merge
2d 2h
Merged PRs (30d)
11

Description

```haxe
class Main {
static function main() {
Abstract.toInt(0);
}
}

abstract Abstract(Int) from Int {
@:to public static function toInt(a:Abstract):Int {
return cast a;
}
}
```

Introduced by https://github.com/HaxeFoundation/haxe/commit/4f15210171949802a0550cf841c88b5695fa7f4f. This used to compile fine, but now errors with:

```
Main.hx:3: characters 3-17 : Cannot access non-static abstract field statically
```

I guess `@:to`-methods are internally treated as not being static, even if they're declared like that? Note: this [breaks Lime](https://github.com/openfl/lime/blob/5.2.1/lime/ui/ScanCode.hx#L252).

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.