haxetink / tink_core

Core utilities
https://haxetink.github.io/tink_core
MIT License
117 stars 33 forks source link

Future.sync() saved to Promise has sticky type on hashlink #172

Open ianxm opened 1 year ago

ianxm commented 1 year ago

This works in --interp and -neko but failes on -hl. There's no problem if the promises have the same type parameters, or if they're typed as Futures even with different type parameters.

        var a :Promise<Int> = Future.sync(2);
        a.handle( ii -> trace('a ${ii.sure()}') );

        var b :Promise<String> = Future.sync("two");
        b.handle( ii -> trace('b ${ii.sure()}') );     // <-- line 10

the error is

TinkFuturePromise.hx:7: a 2
Uncaught exception: Can't cast String to i32
Called from tink.core._Promise.$Promise_Impl_.~ofFuture.0(tink/core/Outcome.hx:13)
Called from tink.core._Future.$Future_Impl_.~map.1(tink/core/Future.hx:97)
Called from tink.core._Lazy.LazyFunc.compute(tink/core/Lazy.hx:106)
Called from tink.core._Lazy.$Lazy_Impl_.get(tink/core/Lazy.hx:13)
Called from tink.core._Future.SyncFuture.handle(tink/core/Future.hx:432)
Called from $TinkFuturePromise.main(TinkFuturePromise.hx:10)
Called from .init(?:1)