HaxeFoundation / HaxeFoundation/haxe

Inconsistent interface type inference for getters/setters

Open
#11,774 3 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

```haxe
interface IObj {
var width(default, null):Float;
var height(get, set):Float;
}

class Main implements IObj {
public var width(default, null) = 0; // Int in this implementation

@:isVar public var height(get, set) = 0.0; // cannot be Int here, but

function get_height():Int { // no signature error
return Std.int(height);
}

function set_height(height:Float):Int { // fine too
return Std.int(height);
}

public function new() {}

static function main() {
final m = new Main();
int(m.width); // fine int
int(m.height); // Error: Float should be Int
}

static function int(v:Int):Void {
trace(v);
}
}
```

Contributor guide

Open the contributing guide

Research direction

Start by compiling the minimal Haxe reproduction in the issue and confirm the differing behavior between width and height. Trace the compiler's interface property and getter/setter type-inference handling. Done means the interface's Float type is enforced consistently and the reproduction no longer accepts incompatible getter or setter signatures.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.