haxetink / tink_await

Haxe async/await
MIT License
58 stars 15 forks source link

Early return from @async function() : Void ends with compile time error at tink_syntaxhub/0,5,0/src/tink/SyntaxHub.hx:35 #45

Open Jens-G opened 2 years ago

Jens-G commented 2 years ago

This is not possible:

 @async static function Foo(tell_us:Bool) : Void {
    if (!tell_us)
        return;  // exit right away

    trace("This is Foo");
}

Since this is a Void function returning null instead (as advised elsewhere) only gives another error.

Library used is the haxelib version.

Full error:

C:\HaxeToolkit\haxe\lib\tink_syntaxhub/0,5,0/src/tink/SyntaxHub.hx:35: characters 5-89 : Expected Array<Field> but got [{name: main, doc: null, pos: #pos(src/Main.hx:14: lines 14-39), access: [AStatic], kind: FFun({ret: null, params: [], expr: {pos: #pos(C:\HaxeToolkit\haxe\lib\tink_syntaxhub/0,5,0/src/tink/SyntaxHub.hx:35: characters 5-89), expr: EBlock(<...>)}, args: []}), meta: [{name: await, params: [], pos: #pos(src/Main.hx:14: characters 2-8)}], name_pos: #pos(src/Main.hx:14: characters 25-29)},{name: Log, doc: null, pos: #pos(src/Main.hx:41: lines 41-45), access: [AStatic], kind: FFun({ret: TPath({name: <...>, params: <...>, pack: <...>}), params: [], expr: {pos: #pos(src/Main.hx:41: lines 41-45), expr: EReturn(<...>)}, args: [{name: <...>, opt: <...>, meta: <...>, type: <...>, name_pos: <...>, value: <...>}]}), meta: [{name: async, params: [], pos: #pos(src/Main.hx:41: characters 2-8)}], name_pos: #pos(src/Main.hx:41: characters 25-28)},{name: Foo, doc: null, pos: #pos(src/Main.hx:47: lines 47-52), access: [AStatic], kind: FFun({ret: TPath({name: <...>, params: <...>, pack: <...>}), params: [], expr: {pos: #pos(src/Main.hx:47: lines 47-52), expr: EReturn(<...>)}, args: [{name: <...>, opt: <...>, meta: <...>, type: <...>, name_pos: <...>, value: <...>}]}), meta: [{name: async, params: [], pos: #pos(src/Main.hx:47: characters 3-9)}], name_pos: #pos(src/Main.hx:47: characters 26-29)}] (see dump/decoding_error.txt for details)
Build halted with errors.