1
0
mirror of https://github.com/fluencelabs/assemblyscript synced 2025-06-30 15:11:45 +00:00

Infer function expressions in matching contexts ()

* legalizes omitting types on function expressions within function type contexts
* legalizes omitting any number of arguments
This commit is contained in:
Daniel Wirtz
2019-02-27 21:45:36 +01:00
committed by GitHub
parent 2945af6557
commit e8b0767143
29 changed files with 1349 additions and 701 deletions

@ -14,3 +14,23 @@ f3();
var f4 = (): i32 => 1;
assert(f4() == 1);
function testOmitted(fn: (a: i32, b: i32) => i32): i32 {
return fn(1, 2);
}
assert(testOmitted((a, b) => a + b) == 3);
assert(testOmitted(a => a) == 1);
assert(testOmitted(() => 42) == 42);
function testOmittedReturn1(): (a: i32, b: i32) => i32 {
return (a, b) => a + b;
}
function testOmittedReturn2(): (a: i32, b: i32) => i32 {
return a => a;
}
function testOmittedReturn3(): (a: i32, b: i32) => i32 {
return () => 42;
}
assert(testOmittedReturn1()(1, 2) == 3);
assert(testOmittedReturn2()(1, 2) == 1);
assert(testOmittedReturn3()(1, 2) == 42);