You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Speculative type parsing in expressions does not always suppress parse errors #3062
In AssemblyScript, the parser speculatively calls parseType with suppressErrors = true during expression lookahead (such as checking for an arrow function return type after (x) : or type arguments after <), but nested paths inside parseType ignore suppressErrors and emit diagnostics instead of backtracking cleanly.
Inside parseType, tryParseFunctionType does not accept suppressErrors and reports errors when seeing ?, and the union | branch hardcodes suppressErrors = false on recursive parseType calls.
Both functions below are valid TypeScript (tsc parses them cleanly) and should compile without error, just as a ? <i32>c : (a ? b : c) and a < (a >> b) do.
Steps to reproduce
exportfunctiontest1(a: bool,b: i32,c: i32): i32{returna ? <i32>(c) : (a ? b : c);}exportfunctiontest2(a: i32,b: i32): bool{returna<(a|(a>>b));}
Compiling with asc repro.ts fails with:
ERROR TS1110: Type expected.
2 │ return a ? <i32>(c) : (a ? b : c);
│ ^
ERROR TS1005: ')' expected.
2 │ return a ? <i32>(c) : (a ? b : c);
│ ~
ERROR TS1005: ')' expected.
6 │ return a < (a | (a >> b));
│ ^
Activity