Fix HTML comments in dynamic Function() and for-in initializer evaluation#2358
Merged
Conversation
…tion
- Fix CreateDynamicFunction body/params wrapping to match spec (step 29/16):
line feeds after params and around body text ensure HTML-like comments
(<!-- and -->) are correctly handled
- Implement AnnexB B.3.6: evaluate for-in loop variable initializer before
enumeration (e.g., `for (var a = ++effects in {})`)
- Remove 6 test262 exclusions (5 HTML comment + 1 for-in initializer)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
lahma
enabled auto-merge (squash)
March 24, 2026 07:22
This was referenced Mar 27, 2026
This was referenced Jun 8, 2026
This was referenced Jun 29, 2026
This was referenced Jul 7, 2026
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.
Summary
<!--and-->) are correctly handled as line commentsfor (var a = ++effects in {}))Details
CreateDynamicFunction (5 tests)
The spec requires specific line feed placement when constructing the source text:
Previously, Jint only added newlines when the content contained
/, which missed HTML-like comments (<!--,-->). Now always follows the spec layout, which correctly handles:Function("\n-->")—-->preceded by line feed is a valid HTML close commentFunction("-->")—-->preceded by line feed (from wrapping) is validFunction("-->", "")—-->in params without preceding line feed correctly throws SyntaxErrorFunction("<!--")—<!--is always a valid HTML open commentFor-in initializer (1 test)
Per AnnexB B.3.6,
for (var a = expr in obj)should evaluate the initializer before enumeration. TheJintForInForOfStatementnow detects when the LHSVariableDeclarationhas a non-nullInitand evaluates it inHeadEvaluationbefore the right-hand expression.Test plan
🤖 Generated with Claude Code