fix(parser): allow HTML close comments on first line per Annex B §B.1.1 - #5512
Closed
xcb3d wants to merge 1 commit into
Closed
fix(parser): allow HTML close comments on first line per Annex B §B.1.1#5512xcb3d wants to merge 1 commit into
xcb3d wants to merge 1 commit into
Conversation
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).
Test262 conformance changes
Fixed tests (3):Broken tests (2):Tested main commit: |
Codecov Report❌ Patch coverage is
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. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
An
HTMLCloseCommentis a valid input element at the start of a script underInputElementHashbangOrRegExp, optionally preceded by whitespace and single-line delimited comments (/* ... */).Previously,
BufferedLexeronly calledskip_html_close()after an existingLineTerminator, causing an initial-->on the first line to be lexed as punctuatorsDec(--) andGreaterThan(>), resulting in an earlySyntaxError.It changes the following:
first_token: booltoBufferedLexerto run an initial skip loop that callsskip_html_close()before and after consuming any initialTokenKind::Commenton the first line.JsNativeErrorKind::Evalmatch arm forErrorType::EvalErrorinboa_tester'sis_error_typecheck.html_close_comment_first_lineincore/parser/src/parser/cursor/buffered_lexer/tests.rs.test/annexB/language/comments/(single-line-html-close-first-line-1.js,2.js,3.js), bringingtest/annexB/language/comments/to 100% conformance (8/8 passed).