Skip to content

Add global variable ($var) type tracking#100

Merged
dak2 merged 1 commit into
mainfrom
fix/global-variable-review-improvements
Mar 26, 2026
Merged

Add global variable ($var) type tracking#100
dak2 merged 1 commit into
mainfrom
fix/global-variable-review-improvements

Conversation

@dak2

@dak2 dak2 commented Mar 26, 2026

Copy link
Copy Markdown
Owner

Motivation

Reading an unregistered global variable ($unknown.upcase) silently dropped the expression from the type graph, producing no diagnostics. Ruby defines uninitialized globals as nil, so this was a false negative.

Changes

  • Return nil-typed vertex for uninitialized global variable reads, matching Ruby semantics
  • Register nil vertex in global variable map to avoid redundant allocations on repeated reads
  • Remove dead class_vars field from Scope
  • Fix inaccurate doc comment referencing non-existent finish_global_var_write
  • Improve Rust test to verify actual type propagation (not just VertexId identity)
  • Add integration tests: same-method write/read, cross-class access, multiple independent globals

Checked

  • cargo test --lib — 33 tests passed

🤖 Generated with Claude Code

@dak2 dak2 force-pushed the fix/global-variable-review-improvements branch from a8c6ceb to 27fad89 Compare March 26, 2026 00:29
Support reading and writing global variables in the type inference
engine. Uninitialized global variable reads are now detected as errors.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@dak2 dak2 force-pushed the fix/global-variable-review-improvements branch from 27fad89 to 9f4f611 Compare March 26, 2026 00:34
@dak2 dak2 changed the title Fix uninitialized global variable read producing no diagnostics Add global variable ($var) type tracking Mar 26, 2026
@dak2 dak2 added this to the v0.2.0 milestone Mar 26, 2026
@dak2 dak2 merged commit 419dc17 into main Mar 26, 2026
4 checks passed
@dak2 dak2 deleted the fix/global-variable-review-improvements branch March 26, 2026 00:37
@dak2 dak2 mentioned this pull request Apr 5, 2026
4 tasks
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