Skip to content

fix: global scope map variables from function returns get correct type#321

Merged
cs01 merged 1 commit intomainfrom
fix-global-map-return
Mar 13, 2026
Merged

fix: global scope map variables from function returns get correct type#321
cs01 merged 1 commit intomainfrom
fix-global-map-return

Conversation

@cs01
Copy link
Copy Markdown
Owner

@cs01 cs01 commented Mar 13, 2026

Summary

  • const m = makeMap() at global scope where makeMap() returns Map<string, string> was incorrectly typed as %Map* (numeric map) instead of %StringMap*, causing invalid LLVM IR
  • Root cause: the map sub-type detection only checked stmt.declaredType and MapNode.keyType, but when the value is a function call, neither is set. Now also extracts key/value types from the resolved expression type
  • Same fix applied for pointer maps (non-string key types)

Test plan

  • New fixture maps/global-map-return.ts — function returning Map<string, string> used at global scope
  • All 616 tests pass
  • Self-hosting verification passes (Stage 0 + Stage 1)

🤖 Generated with Claude Code

@cs01 cs01 merged commit 4c057a0 into main Mar 13, 2026
12 checks passed
@cs01 cs01 deleted the fix-global-map-return branch March 19, 2026 05:23
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