HaxeFoundation / HaxeFoundation/haxe

[cpp,hl/c] native compilation error for Void arguments

Open
#9,678 4 comments 0 reactions 0 assignees View on GitHub
bug platform-cpp
Dominant language
Haxe
Stars
6.9k
Forks
715
Avg merge
2d 2h
Merged PRs (30d)
11

Description

The following was failing with a `VerifyError` on the Flash target and now is failing on native compilation on C++:

```haxe
function f(arg:Void) {}
```

This is of course not normally written, but it can happen that `Void` is inferred through type parameters when void-returning callbacks are involved, like in this simplified example:

```haxe
class C {
var v:T;
public function new(v:T) this.v = v;
public function next(f:()->S):C return new C(f());
public function handle(cb:T->Void) {cb(v);}
}

function returnVoid() {}

function main() {
new C().next(returnVoid).handle(_ -> {});
}
```

Since this is passing haxe type checking all the way to the native compilation, it would be nice to get it fixed.

We can consider this a preparation for https://github.com/HaxeFoundation/haxe-evolution/pull/76. For Flash for now I just made the generator generate the wildcard type (`*`) when Void is used for non-return-type. Maybe something similar could/should be done for C++.

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.