Skip to content

✨ Widen variable types on reassignment via LUB#121

Merged
timfennis merged 1 commit intomasterfrom
feature/reject-incompatible-reassignment
Mar 21, 2026
Merged

✨ Widen variable types on reassignment via LUB#121
timfennis merged 1 commit intomasterfrom
feature/reject-incompatible-reassignment

Conversation

@timfennis
Copy link
Owner

@timfennis timfennis commented Mar 21, 2026

Summary

  • The analyser now tracks type changes on reassignment by computing the LUB of the old and new types and updating the binding
  • This fixes false "not declared" errors when destructuring a variable that was initialized as () and later reassigned to a tuple (e.g. let pos = (); pos = (1, 2); let a, b = pos;)
  • Documents reassignment type widening in the manual

Test plan

  • All 268 tests pass
  • Regression test bug0015 verifies the original bug is fixed
  • cargo clippy and cargo fmt clean

🤖 Generated with Claude Code

The analyser now tracks type changes when a variable is reassigned by
computing the LUB of the old and new types and updating the binding.
This fixes false "not declared" errors when destructuring a variable
that was initialized as () and later reassigned to a tuple.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@timfennis timfennis force-pushed the feature/reject-incompatible-reassignment branch from ee39b2f to c7db1a6 Compare March 21, 2026 22:14
@timfennis timfennis changed the title ✨ Reject incompatible type reassignment ✨ Widen variable types on reassignment via LUB Mar 21, 2026
@timfennis timfennis merged commit 323a994 into master Mar 21, 2026
1 check passed
@timfennis timfennis deleted the feature/reject-incompatible-reassignment branch March 21, 2026 22: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