[email protected]:
unknown: Unexpected token (1:4)
> 1 | a(b?: T1): T2 ->
| ^
2 | switch
3 |
The parser is misattributing the syntax error to the function arg list, rather than the body. Removing the return type annotation fixes this and gives the proper syntax error:
unknown: Illegal newline. (2:8)
1 | a(b?: T1) ->
> 2 | switch
| ^
3 |
I have traced the problem to this area:
https://github.com/lightscript/babylon-lightscript/blob/master/src/parser/expression.js#L477
I think the preceding code, when it tries to speculatively parse a function with a flowtype, is encountering an error in the body and eating it/resetting the state. Then because the refShorthandDefaultPos is set, the error appears outside the function body.
No suggested fix yet but I am looking into it.
[email protected]:The parser is misattributing the syntax error to the function arg list, rather than the body. Removing the return type annotation fixes this and gives the proper syntax error:
I have traced the problem to this area:
https://github.com/lightscript/babylon-lightscript/blob/master/src/parser/expression.js#L477
I think the preceding code, when it tries to speculatively parse a function with a flowtype, is encountering an error in the body and eating it/resetting the state. Then because the
refShorthandDefaultPosis set, the error appears outside the function body.No suggested fix yet but I am looking into it.