Void in Generic Function Typing

38 views
Skip to first unread message

Christopher Johnson

unread,
May 25, 2014, 6:34:27 PM5/25/14
to haxe...@googlegroups.com
I'm trying to compile code like:

class Promise_Test<T>{
public function new() { }

public function then<A>(f : T->A) { }

public static function test() {
new Promise_Test<Void>()
.then(function() { } );
}
}

But I get an error: "Void -> Void should be (Void) -> Unknown<0>."

If I replace T->A with Void->A then it successfully compiles.

If I replace T->A with T->Void then I get an error: "Void -> Void should be (Void) -> Void."

I have three questions:
  1. Where is the Unknown<0> coming from?
  2. What is the difference between Void and (Void)?
  3. Is there a way to pass Void->Void arguments to then() ?

Reply all
Reply to author
Forward
0 new messages