Skip to content

Fix ASI not firing before <template> in class bodies#19

Open
andsmedeiros wants to merge 1 commit into
ember-tooling:mainfrom
andsmedeiros:main
Open

Fix ASI not firing before <template> in class bodies#19
andsmedeiros wants to merge 1 commit into
ember-tooling:mainfrom
andsmedeiros:main

Conversation

@andsmedeiros
Copy link
Copy Markdown

The upstream JS scanner suppresses automatic semicolon insertion before < because in standard JS it could be a less-than operator. In GJS/GTS, <template> is a valid class body member, which caused field definitions without a trailing semicolon to not be recognised when followed by a template tag.

Fix this in scanner.c by intercepting the AUTOMATIC_SEMICOLON case before delegating to the JS scanner. We call scan_automatic_semicolon directly (accessible from the included scanner.h), and when it refuses due to <, we peek ahead for template> and emit the semicolon ourselves.

@NullVoxPopuli
Copy link
Copy Markdown
Member

looks like tests are failing :(

@andsmedeiros
Copy link
Copy Markdown
Author

The issue is actually a version incompatibility between tree-sitter/tree-sitter and tree-sitter/setup-action: tree-sitter/setup-action@2a73b29

The action version used in this repository is too old to be used with recent tree-sitter versions; the solution would be updating it, but I feel it is maybe out of scope for this PR?

@NullVoxPopuli
Copy link
Copy Markdown
Member

, but I feel it is maybe out of scope for this PR?

def -- just wasn't expecting surprise maintenance 🙈

@NullVoxPopuli
Copy link
Copy Markdown
Member

Just needs rebase now

The upstream JS scanner suppresses automatic semicolon insertion before
`<` because in standard JS it could be a less-than operator. In GJS/GTS,
`<template>` is a valid class body member, which caused field definitions
without a trailing semicolon to not be recognised when followed by a
template tag.

Fix this in scanner.c by intercepting the AUTOMATIC_SEMICOLON case before
delegating to the JS scanner. We call scan_automatic_semicolon directly
(accessible from the included scanner.h), and when it refuses due to `<`,
we peek ahead for `template>` and emit the semicolon ourselves.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.

2 participants