assemblyscript icon indicating copy to clipboard operation
assemblyscript copied to clipboard

#1125 Fix parsing of unusual trailing expressions separated by whitespace

Open technohippy opened this issue 3 years ago • 3 comments

Concerning:

  • Is "unexpected token error" appropriate for this error?

  • Serialized source text still has ";". Is it OK?

  • [x] I've read the contributing guidelines

  • [x] I've added my name and email to the NOTICE file

technohippy avatar Apr 07 '22 15:04 technohippy

I wonder whether this is only applicable to variables and returns. Another one that comes to mind is throw. Do you know what the spec says exactly for this case? If it runs deeper, perhaps a fix could be more general.

dcodeIO avatar Apr 09 '22 07:04 dcodeIO

I wonder whether this is only applicable to variables and returns. Another one that comes to mind is throw. Do you know what the spec says exactly for this case? If it runs deeper, perhaps a fix could be more general.

I agree. I don't know the spec well but I should consider more deeply.

Anyway, this change counts some valid codes like below as an error.

function foo(): i32 {
  return 123 }

I'll close this pullreq for now and reopen it after making more proper solution.

technohippy avatar Apr 09 '22 15:04 technohippy

I read the spec but it's too complecated for me to handle all cases.

  • https://tc39.es/ecma262/#sec-automatic-semicolon-insertion

Anyway, this pull req can fix issue #1125. If other cases are found, please replace tn.skip(Token.SEMICOLON) to this.checkRuleCompleted(tn).

technohippy avatar Apr 11 '22 15:04 technohippy

Thanks :) There are likely more ASI-related issues, but seems good to have this merged for the (probably most prominent) cases covered herein.

dcodeIO avatar Jan 08 '23 13:01 dcodeIO