Closed serjek closed 1 year ago
checked with haxe 4.1.2 and 4.1.3
Apparently same applies to Promise.NOISE
as well.
Hmm, after the changes to NEVER this seems to work fine.
still repro:
final p = function():Promise<Int> return Promise.resolve(42);
p().next(v -> if (v == 42) Promise.NEVER else "okay").handle(function(o) trace(o));
String should be tink.core.Promise<tink.core.Never>
And yes it will compile just fine if string comes first in condition.
But this time wrapping string to Promise.resolve
does not help ;(
I reverted the change due to #158
Note, now this works with haxe 4.1.5 but does repro with 4.2.2
Current workaround is to explicitly type-hint the NEVER value:
final promise = if (v == 42) (Promise.NEVER:Promise<String>) else "okay";
As @nadako suggested, we should probably add static public function never<X>():Promise<X>
to Promise
and advertise that instead.
The suggestions from the above comment was actually implemented a while ago.
Consider the following:
it will give compilation error unless
Promise.NEVER
is put after thedata
or data is wrapped toPromise.resolve
. Note that function already has type hint, but it does not help the compiler to cast thePromise.NEVER
properly.