Skip to content

🐛 fix(eval): prevent stack overflow when user function shadows a builtin#1734

Merged
harehare merged 1 commit into
mainfrom
fix/shadow-builtin-stack-overflow
May 13, 2026
Merged

🐛 fix(eval): prevent stack overflow when user function shadows a builtin#1734
harehare merged 1 commit into
mainfrom
fix/shadow-builtin-stack-overflow

Conversation

@harehare
Copy link
Copy Markdown
Owner

When a user-defined function has the same name as a native builtin, calls to that name within the function body now resolve to the native builtin instead of recursing back into the user-defined function.

This is done by binding NativeFunction(ident) into the body's new_env whenever the called function name matches a known builtin. As a result, the outer scope continues to use the user-defined version (override semantics), while the body can safely call the same-named builtin.

When a user-defined function has the same name as a native builtin,
calls to that name within the function body now resolve to the native
builtin instead of recursing back into the user-defined function.

This is done by binding NativeFunction(ident) into the body's new_env
whenever the called function name matches a known builtin. As a result,
the outer scope continues to use the user-defined version (override
semantics), while the body can safely call the same-named builtin.
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented May 13, 2026

Merging this PR will not alter performance

✅ 29 untouched benchmarks


Comparing fix/shadow-builtin-stack-overflow (e20f05e) with main (19c291a)1

Open in CodSpeed

Footnotes

  1. No successful run was found on main (6be1b19) during the generation of this report, so 19c291a was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@harehare harehare merged commit 139c3db into main May 13, 2026
10 checks passed
@harehare harehare deleted the fix/shadow-builtin-stack-overflow branch May 13, 2026 12:51
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