Skip to content

fix: support map and set at global scope#203

Merged
cs01 merged 1 commit intomainfrom
fix/global-map-segfault
Mar 11, 2026
Merged

fix: support map and set at global scope#203
cs01 merged 1 commit intomainfrom
fix/global-map-segfault

Conversation

@cs01
Copy link
Copy Markdown
Owner

@cs01 cs01 commented Mar 11, 2026

Summary

  • Global-scope Map<string, *> and Set<string> now work instead of erroring with "wrap in a function"
  • Root cause: global variables use pointer-to-pointer indirection (@m is %StringMap**, not %StringMap*). Method dispatch and variable expression generation passed the raw global address to map/set operations that expected a direct struct pointer.
  • Fixed in 3 places: variables.ts (expression generation loads through global pointer), method-calls.ts (map/set method dispatch loads through global pointer), llvm-generator.ts (restored global map declaration with proper metadata)

Test plan

  • New test: map-global-scope.ts — global map set/get/has/size
  • New test: set-global-scope.ts — global set add/has/size
  • All 464 tests pass
  • Self-hosting verification passes (Stage 0 + Stage 1)

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@cs01 cs01 merged commit 3b5ce40 into main Mar 11, 2026
12 checks passed
@cs01 cs01 deleted the fix/global-map-segfault branch March 11, 2026 02: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