botsman / hxasync

This library allows you to add "async" and "await" keywords in Python and JavaScript code almost the same way you would do it in the native code.
MIT License
22 stars 3 forks source link

Type safety / static async check #22

Open fed239 opened 2 years ago

fed239 commented 2 years ago

Would it possible to do so that when @async is used with a function, its type is change, so if @await is not used when calling the function type checking would fail?

Example

@async function returnZero(): Int {
  return 0;
}

var i: Int = @await returnZero(); // compilation succeeds
var p: Promise<Int> = returnZero(); // compilation succeeds
var i2: Int = returnZero(); // compilation fails
botsman commented 2 years ago

I've tried to implement type checking, but did not manage to do that, unfortunately.
I guess that I am not good enough with Haxe macro system.