Skip to content

fix(parser): allow HTML close comments on first line per Annex B §B.1.1 - #5512

Closed
xcb3d wants to merge 1 commit into
boa-dev:mainfrom
xcb3d:fix/annex-b-first-line-html-close-comment
Closed

fix(parser): allow HTML close comments on first line per Annex B §B.1.1#5512
xcb3d wants to merge 1 commit into
boa-dev:mainfrom
xcb3d:fix/annex-b-first-line-html-close-comment

Conversation

@xcb3d

@xcb3d xcb3d commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

This Pull Request allows single-line HTML close comments (-->) to appear on the first line of a script per ECMAScript Annex B §B.1.1.

According to ECMAScript Annex B §B.1.1:

InputElementHashbangOrRegExp ::
    WhiteSpace
    LineTerminator
    Comment
    CommonToken
    HashbangComment
    RegularExpressionLiteral
    HTMLCloseComment

HTMLCloseComment ::
    WhiteSpaceSequence[opt] SingleLineDelimitedCommentSequence[opt] --> SingleLineCommentChars[opt]

An HTMLCloseComment is a valid input element at the start of a script under InputElementHashbangOrRegExp, optionally preceded by whitespace and single-line delimited comments (/* ... */).

Previously, BufferedLexer only called skip_html_close() after an existing LineTerminator, causing an initial --> on the first line to be lexed as punctuators Dec (--) and GreaterThan (>), resulting in an early SyntaxError.

It changes the following:

  • Add first_token: bool to BufferedLexer to run an initial skip loop that calls skip_html_close() before and after consuming any initial TokenKind::Comment on the first line.
  • Add missing JsNativeErrorKind::Eval match arm for ErrorType::EvalError in boa_tester's is_error_type check.
  • Add parser unit test html_close_comment_first_line in core/parser/src/parser/cursor/buffered_lexer/tests.rs.
  • Resolves all 3 failing test262 tests in test/annexB/language/comments/ (single-line-html-close-first-line-1.js, 2.js, 3.js), bringing test/annexB/language/comments/ to 100% conformance (8/8 passed).

Per ECMAScript Annex B §B.1.1, HTML close comments (`-->`) are permitted on the first line of a script (under `InputElementHashbangOrRegExp`), optionally preceded by whitespace and single-line delimited comments (`/* ... */`).

Previously, `BufferedLexer` only skipped HTML close comments after a preceding `LineTerminator`, which caused files with `-->` on the first line to be lexed as punctuator `--` followed by `>`, triggering a `SyntaxError`.

Also add missing `JsNativeErrorKind::Eval` match arm in `boa_tester`'s `is_error_type` check for `ErrorType::EvalError`.

This resolves all 3 failing test262 tests in `test/annexB/language/comments/`, bringing the suite to 100% conformance (8/8 passed).
@xcb3d
xcb3d requested a review from a team as a code owner September 6, 2026 15:21
@github-actions github-actions Bot added the Waiting On Review Waiting on reviews from the maintainers label Sep 6, 2026
@github-actions github-actions Bot added this to the v0.23 milestone Sep 6, 2026
@github-actions github-actions Bot added C-Parser Issues surrounding the parser C-Tests Issues and PRs related to the tests. labels Sep 6, 2026
@github-actions

github-actions Bot commented Sep 6, 2026

Copy link
Copy Markdown

Test262 conformance changes

Test result main count PR count difference
Total 53,578 53,578 0
Passed 51,426 51,427 +1
Ignored 1,648 1,648 0
Failed 504 503 -1
Panics 0 0 0
Conformance 95.98% 95.99% +0.00%
Fixed tests (3):
test/annexB/language/comments/single-line-html-close-first-line-3.js (previously Failed)
test/annexB/language/comments/single-line-html-close-first-line-1.js (previously Failed)
test/annexB/language/comments/single-line-html-close-first-line-2.js (previously Failed)
Broken tests (2):
test/annexB/built-ins/Function/createdynfn-no-line-terminator-html-close-comment-params.js (previously Passed)
test/language/comments/hashbang/preceding-whitespace.js (previously Passed)

Tested main commit: 4b61183443403997a98da829dae287ce10358e1c
Tested PR commit: 38d9c7e320bd1676c12c1d027512a1d5d9aeac1a
Compare commits: 4b61183...38d9c7e

@xcb3d xcb3d closed this Sep 6, 2026
@github-actions github-actions Bot removed the Waiting On Review Waiting on reviews from the maintainers label Sep 6, 2026
@codecov

codecov Bot commented Sep 6, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.66667% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 62.77%. Comparing base (6ddc2b4) to head (38d9c7e).
⚠️ Report is 1051 commits behind head on main.

Files with missing lines Patch % Lines
tests/tester/src/exec/mod.rs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main    #5512       +/-   ##
===========================================
+ Coverage   47.24%   62.77%   +15.52%     
===========================================
  Files         476      536       +60     
  Lines       46892    60297    +13405     
===========================================
+ Hits        22154    37849    +15695     
+ Misses      24738    22448     -2290     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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

Labels

C-Parser Issues surrounding the parser C-Tests Issues and PRs related to the tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant