Skip to content

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

Description

@nadako

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

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:

class C<T> {
	var v:T;
	public function new(v:T) this.v = v;
	public function next<S>(f:()->S):C<S> 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 HaxeFoundation/haxe-evolution#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++.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugplatform-cppEverything related to CPP / C++

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions