Skip to content

fix: improve error messages for set, map, constructor, and control flow errors#186

Merged
cs01 merged 1 commit intomainfrom
codegen-throw-to-emiterror-2
Mar 10, 2026
Merged

fix: improve error messages for set, map, constructor, and control flow errors#186
cs01 merged 1 commit intomainfrom
codegen-throw-to-emiterror-2

Conversation

@cs01
Copy link
Copy Markdown
Owner

@cs01 cs01 commented Mar 10, 2026

Summary

  • Converts 14 throw new Error() calls to emitError() across Set, Map, Literals, control flow, and member access codegen
  • Users now see clean error: file.ts:5:3 — Set.add() requires exactly 1 argument instead of a raw JavaScript stack trace

What this means for users

When you make a mistake like calling mySet.add() without arguments, new Set() without a type parameter, or using break outside a loop, you'll now get a clear error message pointing to the exact file and line — instead of an intimidating stack trace that looks like the compiler crashed.

Affected errors

  • Set.add/has/delete() argument count
  • Map.set/get/has/delete() argument count
  • new Set() missing type argument
  • new RegExp/Uint8Array/URL() missing arguments
  • this keyword outside class context
  • break/continue outside loop
  • For-loop variable missing initializer

Test plan

  • All 451 compiler tests pass
  • Self-hosting Stage 0 + Stage 1 pass
  • Format check passes

🤖 Generated with Claude Code

@cs01 cs01 merged commit 597369d into main Mar 10, 2026
12 checks passed
@cs01 cs01 deleted the codegen-throw-to-emiterror-2 branch March 10, 2026 21:28
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