Skip to content

fix: Align the ASI behaviour with typescript - #3053

Open
Changqing-JING wants to merge 2 commits into
AssemblyScript:mainfrom
Changqing-JING:fix/parser
Open

Changqing-JING wants to merge 2 commits into
AssemblyScript:mainfrom
Changqing-JING:fix/parser

Conversation

@Changqing-JING

@Changqing-JING Changqing-JING commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #2130

Changes proposed in this pull request:
Align the ASI behaviour with typescript

  • I've read the contributing guidelines
  • I've added my name and email to the NOTICE file

@Changqing-JING Changqing-JING changed the title Fix/parser Align the ASI behaviour with typescript Oct 17, 2026
@Changqing-JING Changqing-JING changed the title Align the ASI behaviour with typescript fix: Align the ASI behaviour with typescript Oct 17, 2026
@Changqing-JING
Changqing-JING marked this pull request as draft October 17, 2026 09:10
@Changqing-JING

Copy link
Copy Markdown
Contributor Author

@JairusSW JairusSW self-assigned this Oct 21, 2026
@JairusSW

Copy link
Copy Markdown
Member

@Changqing-JING, taking a look

Comment thread src/parser.ts
let ret = Node.createExpressionStatement(expr);
tn.skip(Token.Semicolon);
if (isFor) tn.skip(Token.Semicolon);
else this.parseSemicolon(tn);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't isFor not fire in a nested func declaration?
eg.

export function foo(): i32 {
  function bar(): i32 { return 42; } return bar();
}

on my end, it panics when a nested function is followed by a statement on the same line as the closing brace.

Comment thread src/parser.ts

// Name<T>
if (tn.skip(Token.LessThan)) {
if (!tn.peekOnNewLine() && tn.skip(Token.LessThan)) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might affect generics (< token) when it's on a new line. For example,

class Foo<T> {}
class Bar extends Foo
<string> {}

should fail i think?

@JairusSW

Copy link
Copy Markdown
Member

Generally, looks good. Please fix the issues i found and it'd probably be good to add a test for them as well

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Proposal] Error on ASI ambiguous cases

2 participants