Skip to content

Fix uninitialized @@var reads silently skipping downstream type checking#101

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

Fix uninitialized @@var reads silently skipping downstream type checking#101
dak2 merged 1 commit into
mainfrom
fix/class-variable-review-improvements

Conversation

@dak2

@dak2 dak2 commented Mar 27, 2026

Copy link
Copy Markdown
Owner

Motivation

PR #99 introduced class variable (@@var) type tracking, but it has a issue that uninitialized @@var reads returned NotHandled, silently skipping all downstream method call type checking

Changes

  • Add nil fallback for uninitialized @@var reads (matching the global variable pattern) so method chains like @@data.upcase are always type-checked
  • Replace .expect() with defensive if let Some pattern in set_class_var_in_class for consistency
  • Move test_class_variable_write_before_read to correct "No Error" section
  • Add tests: class-body write type error, cross-class @@var isolation, module-scope resilience

Checked

  • cargo test --lib
  • ruby -Ilib -Itest test/class_variable_test.rb

🤖 Generated with Claude Code

@dak2 dak2 changed the title Fix class variable (@@var) review improvements Fix uninitialized @@var reads silently skipping downstream type checking Mar 27, 2026
@dak2 dak2 changed the title Fix uninitialized @@var reads silently skipping downstream type checking Fix uninitialized @@var reads silently skipping downstream type checking Mar 27, 2026
@dak2 dak2 force-pushed the fix/class-variable-review-improvements branch from 96ca50d to 2aa4994 Compare March 27, 2026 00:45
…cking

When `@@var` was read before being written, install_class_var_read
returned None, which propagated through the ? operator and caused
the entire method call chain (e.g. @@data.upcase) to be silently
dropped from type checking — producing neither errors nor warnings.

Fall back to a nil vertex on uninitialized reads, matching the
existing global variable ($var) pattern, so downstream method calls
are always type-checked.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@dak2 dak2 force-pushed the fix/class-variable-review-improvements branch from 2aa4994 to 13cc821 Compare March 28, 2026 02:00
@dak2 dak2 merged commit 505e311 into main Mar 28, 2026
4 checks passed
@dak2 dak2 deleted the fix/class-variable-review-improvements branch March 28, 2026 02:04
@dak2 dak2 added this to the v0.2.0 milestone Mar 28, 2026
@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