HaxeFoundation / HaxeFoundation/haxe
static assign-ops overloads should be forbidden?
Open
feature-abstracts
- Dominant language
- Haxe
- Stars
- 6.9k
- Forks
- 715
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 11
Description
Something like this does not make much sense and it doesn't work, even if `addAssign` is `inline`, because `a` will be tempvared.
```haxe
abstract A(Int) from Int {
function asInt() return this;
@:op(a += b) static function addAssign(a:Int, b:A):Int {
return a += b.asInt();
}
}
class Main {
static function main() {
var a = 10;
var b:A = 5;
a += b;
trace(a); // still 10
}
}
```
I think assign-ops only make sense when `this` can be asssigned to, that is, `inline` non-`static` methods. So should we error on this kind of `@:op` definitions?
Contributor guide
Assessment
This issue has not been assessed yet.