Commit 323a994
✨ Widen variable types on reassignment via LUB (#121)
## 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
- [x] All 268 tests pass
- [x] Regression test `bug0015` verifies the original bug is fixed
- [x] `cargo clippy` and `cargo fmt` clean
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Claude Opus 4.6 <[email protected]>1 parent 4cdadc7 commit 323a994
3 files changed
Lines changed: 35 additions & 2 deletions
File tree
- manual/src/reference
- ndc_analyser/src
- tests/programs/900_bugs
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
43 | 61 | | |
44 | 62 | | |
45 | 63 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
81 | | - | |
82 | | - | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
83 | 97 | | |
84 | 98 | | |
85 | 99 | | |
| |||
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
| |||
0 commit comments