Skip to content

fix: accept unterminated block comments at EOF in scanner#232

Merged
VladimirMakaev merged 1 commit intofwcd:mainfrom
VladimirMakaev:fix/unterminated-block-comments
Feb 19, 2026
Merged

fix: accept unterminated block comments at EOF in scanner#232
VladimirMakaev merged 1 commit intofwcd:mainfrom
VladimirMakaev:fix/unterminated-block-comments

Conversation

@VladimirMakaev
Copy link
Copy Markdown
Collaborator

Summary

  • Scanner now accepts unterminated /* comments at EOF as valid multiline_comment tokens, matching JetBrains PSI behavior
  • Previously, unterminated comments caused tree-sitter to parse /* as multiplication/spread operators
  • Added lexer->eof(lexer) guard so '\0' is only treated as EOF when it truly is

Impact

  • 4 BlockCommentAtBeginningOfFile fixtures now MATCH (2 were MISMATCH, 2 were TS_PARSE_ERROR)
  • Cross-validation: 97/124 (78.2%) → 101/126 (80.2%)
  • 4 new corpus tests, all pass — no regressions

Test plan

  • npm test — all 239 tests pass
  • npm run cross-validate — 101/126 match rate
  • npx tree-sitter parse on all 4 BlockComment fixtures — clean parse trees

The scanner previously rejected unterminated /* comments at EOF,
causing tree-sitter to parse the comment delimiters as operators
(multiplicative_expression, spread_expression). This matches JetBrains
PSI behavior which recognizes unclosed /* as a BLOCK_COMMENT token.

Fixes 4 cross-validation fixtures (BlockCommentAtBeginningOfFile 1-4),
improving match rate from 97/124 (78.2%) to 101/126 (80.2%).
@github-actions github-actions bot added the scanner Related to the external scanner label Feb 19, 2026
@VladimirMakaev VladimirMakaev marked this pull request as ready for review February 19, 2026 21:07
@VladimirMakaev VladimirMakaev merged commit b136726 into fwcd:main Feb 19, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scanner Related to the external scanner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant