HaxeFoundation / HaxeFoundation/haxe

`$bind` generated for fields with function types

Open
#6,316 7 comments 0 reactions 2 assignees Claimed by @ncannasse View on GitHub
discussion
Dominant language
Haxe
Stars
6.9k
Forks
715
Avg merge
2d 2h
Merged PRs (30d)
11

Description

In [this](https://try.haxe.org/#BC415) code, all traces should yield `true`:

```haxe
typedef HasFunc = {
var func(default, null):Void->Void;
}
typedef HasFunc2 = {
var func(default, default):Void->Void;
}
typedef HasFuncOf = {
@:optional var func(default, null):T;
}
class HasFunc3 {
public var func(default, null):T;
public function new(func:T) {
this.func = func;
}
}
class Test {
static function main() {
trace(({ func: main } : HasFunc).func == main);//false
trace(({ func: main } : HasFunc2).func == main);//true - because (default, default)
trace(({ func: main } : HasFuncOfVoid>).func == main);//false
trace(compare({ func: main }, main));//true - because compare doesn't know concrete field type

var o = new HasFunc3(main);
trace(o.func == main);//true because it's an instance rather than an anonymous structure
var o:HasFunc = o;//the same instance typed differently:
trace(o.func == main);//false

trace(({ } : HasFuncOfVoid>).func == null);//true on js, but on interp and neko it throws "Can't create closure : value is not a function".
}
static function compare(o:HasFuncOf, v:T)
return o.func == 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.