Skip to content

Align JavaScript runtime error messages with V8/Node.js#2367

Merged
lahma merged 1 commit into
sebastienros:mainfrom
lahma:align-error-messages
Mar 26, 2026
Merged

Align JavaScript runtime error messages with V8/Node.js#2367
lahma merged 1 commit into
sebastienros:mainfrom
lahma:align-error-messages

Conversation

@lahma

@lahma lahma commented Mar 26, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Add missing error messages to ~110 bare Throw.TypeError/RangeError/SyntaxError calls that previously produced empty errors
  • Correct ~40 existing error messages that didn't match V8/Node.js output
  • All messages validated against Node.js locally

Key changes

  • Constructors: Added "Constructor X requires 'new'" to 15 constructors
  • TypedArray/ArrayBuffer/SharedArrayBuffer: Added slice validation, type check, and reduce messages
  • Prototype methods: Added "X.prototype.Y requires that 'this' be a Z" for Number, Boolean, BigInt, String, Symbol
  • Property access: Updated to modern V8 format "Cannot read properties of X (reading 'Y')"
  • Iterator helpers: Fixed "Invalid limit""{value} must be positive" to match Node.js
  • Various fixes: Object.defineProperties typo, Number.prototype.toFixed() prefix, Promise "resolver" vs "executor", RegExp flag getter messages, "Invalid left-hand side in assignment", BigInt >>> specific message, and more

Scope

Only user-facing JavaScript runtime errors (TypeError, RangeError, SyntaxError, ReferenceError). Internal CLR exceptions (NotImplementedException, ArgumentException, etc.) are out of scope.

Test plan

  • dotnet test --configuration Release Jint.Tests/Jint.Tests.csproj — 2784 passed, 0 failed
  • dotnet test --configuration Release Jint.Tests.Test262/Jint.Tests.Test262.csproj — 95,985 passed, 0 failed
  • Updated 6 test assertions in ErrorTests.cs for new property access error format
  • REPL spot-checks verified messages match Node.js output

🤖 Generated with Claude Code

Add missing error messages to ~110 bare Throw.TypeError/RangeError/SyntaxError
calls and correct ~40 existing messages that didn't match V8 output. All
messages were validated against Node.js locally.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@lahma
lahma force-pushed the align-error-messages branch from 7162cef to 5e679bb Compare March 26, 2026 09:39
@lahma
lahma enabled auto-merge (squash) March 26, 2026 09:42
@lahma
lahma merged commit 08139b1 into sebastienros:main Mar 26, 2026
4 checks passed
@lahma
lahma deleted the align-error-messages branch March 26, 2026 09:45
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