Skip to content

@async short lambdas not unpacked correctly? #38

@cambiata

Description

@cambiata

Using tink_await 0.6.0, oldschool anonymous functions work as expected, but arrowfunctions don't - the return value isn't unpacked correctly. Noticed when trying Future.ofJsPromise as below, but the same seems to happen when using all Futures:

@await class Main {
	@async static function main() {	
		
		// This works fine:
		js.Browser.document.onmousedown = @async function(e) {
		 	var int = @await Future.ofJsPromise(testJsPromise());
		 	trace(int);	// traces 1234
		};

		// This doesn't:
		js.Browser.document.onmousedown = @async (e)-> {
			var int = @await Future.ofJsPromise(testJsPromise());
			trace(int);	// traces the promise method	
		};
	}

	static function testJsPromise():Promise<Int> {
		return new Promise<Int>((res, rej)->{
			haxe.Timer.delay(()->res(1234), 1000);
		});
	}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions