Skip to content

Fix HTML comments in dynamic Function() and for-in initializer evaluation#2358

Merged
lahma merged 1 commit into
sebastienros:mainfrom
lahma:fix-exclusions
Mar 24, 2026
Merged

Fix HTML comments in dynamic Function() and for-in initializer evaluation#2358
lahma merged 1 commit into
sebastienros:mainfrom
lahma:fix-exclusions

Conversation

@lahma

@lahma lahma commented Mar 24, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Fix CreateDynamicFunction wrapping to match spec (steps 16/29): line feeds after params and around body text ensure HTML-like comments (<!-- and -->) are correctly handled as line comments
  • 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), all now passing

Details

CreateDynamicFunction (5 tests)

The spec requires specific line feed placement when constructing the source text:

sourceText = prefix + " anonymous(" + P + "\n) {\n" + bodyText + "\n}"

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 comment
  • Function("-->")--> preceded by line feed (from wrapping) is valid
  • Function("-->", "")--> in params without preceding line feed correctly throws SyntaxError
  • Function("<!--")<!-- is always a valid HTML open comment

For-in initializer (1 test)

Per AnnexB B.3.6, for (var a = expr in obj) should evaluate the initializer before enumeration. The JintForInForOfStatement now detects when the LHS VariableDeclaration has a non-null Init and evaluates it in HeadEvaluation before the right-hand expression.

Test plan

  • All 6 previously-excluded test262 tests now pass
  • Full test262 suite: 0 failures, 95999 passed
  • Jint.Tests: 0 failures, 2781 passed

🤖 Generated with Claude Code

…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
lahma enabled auto-merge (squash) March 24, 2026 07:22
@lahma
lahma merged commit 9a948fe into sebastienros:main Mar 24, 2026
4 checks passed
@lahma
lahma deleted the fix-exclusions branch March 24, 2026 07:33
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.

1 participant