HaxeFoundation / HaxeFoundation/haxe

Abstract inline set

Open
#12,422 7 comments 0 reactions 0 assignees View on GitHub
Dominant language
Haxe
Stars
6.9k
Forks
715
Avg merge
2d 2h
Merged PRs (30d)
11

Description

Inlining an abstract function that modifies `this` is valid. This is used for example in haxe.EnumFlags.
However, this does not work when the variable is stored in a property. The setter will not be called, as the following example shows:

```haxe
abstract X(Int) {
public function new(v:Int) { this = v; }
public inline function incr() { this++; }
}

class Test {
static var B(default,set) : X;
static function main() {
var a = new X(3);
a.incr();
trace(a); // 4, ok !
B = new X(3);
B.incr(); // no set_4 !
}
static function set_B(v:X) {
trace("SET:"+v);
return v;
}

}
```

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.