Commit 0388c46
fix(interpreter): detect cyclic nameref to prevent wrong resolution (#465)
## Summary
- Cyclic namerefs (a->b->a) silently resolved to a wrong variable
- Added HashSet-based visited tracking in `resolve_nameref()` to detect
cycles
- Returns the original name when a cycle is detected
## Test plan
- [x] Unit test: `test_cyclic_nameref_detected`
Closes #426
Co-authored-by: Claude <noreply@anthropic.com>1 parent e40a5f6 commit 0388c46
1 file changed
+21
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7639 | 7639 | | |
7640 | 7640 | | |
7641 | 7641 | | |
| 7642 | + | |
| 7643 | + | |
7642 | 7644 | | |
7643 | 7645 | | |
7644 | 7646 | | |
7645 | | - | |
7646 | | - | |
| 7647 | + | |
| 7648 | + | |
| 7649 | + | |
| 7650 | + | |
| 7651 | + | |
7647 | 7652 | | |
7648 | 7653 | | |
7649 | 7654 | | |
| |||
9542 | 9547 | | |
9543 | 9548 | | |
9544 | 9549 | | |
| 9550 | + | |
| 9551 | + | |
| 9552 | + | |
| 9553 | + | |
| 9554 | + | |
| 9555 | + | |
| 9556 | + | |
| 9557 | + | |
| 9558 | + | |
| 9559 | + | |
| 9560 | + | |
| 9561 | + | |
| 9562 | + | |
| 9563 | + | |
9545 | 9564 | | |
0 commit comments