Commit 0bf8dd6
Fix stack overflow with self-referential variable definitions
Add cycle detection to evalLookupLocal for top-level definitions to
prevent infinite recursion when a variable references itself (e.g., a = a).
The fix adds tracking of definitions currently being evaluated using
the existing def_stack mechanism. When a lookup encounters a definition
that is already in progress, it either creates a placeholder for
recursive functions or triggers a crash with a clear error message
for non-function circular references.
Also adds a regression test for issue #8942.
Co-Authored-By: Claude <noreply@anthropic.com>1 parent 4a9db50 commit 0bf8dd6
File tree
2 files changed
+50
-2
lines changed- src/eval
- test/snapshots/issue
2 files changed
+50
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13803 | 13803 | | |
13804 | 13804 | | |
13805 | 13805 | | |
| 13806 | + | |
| 13807 | + | |
| 13808 | + | |
| 13809 | + | |
| 13810 | + | |
| 13811 | + | |
| 13812 | + | |
| 13813 | + | |
| 13814 | + | |
| 13815 | + | |
| 13816 | + | |
| 13817 | + | |
| 13818 | + | |
| 13819 | + | |
| 13820 | + | |
| 13821 | + | |
| 13822 | + | |
| 13823 | + | |
| 13824 | + | |
| 13825 | + | |
| 13826 | + | |
| 13827 | + | |
| 13828 | + | |
| 13829 | + | |
| 13830 | + | |
| 13831 | + | |
| 13832 | + | |
| 13833 | + | |
| 13834 | + | |
13806 | 13835 | | |
13807 | 13836 | | |
13808 | 13837 | | |
13809 | | - | |
13810 | | - | |
| 13838 | + | |
| 13839 | + | |
| 13840 | + | |
| 13841 | + | |
| 13842 | + | |
13811 | 13843 | | |
13812 | 13844 | | |
13813 | 13845 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
0 commit comments