Skip to content

Let Rust registrations override prelude definitions - #121

Merged
shsms merged 1 commit into
mainfrom
rust-registration-overrides-prelude
May 29, 2026
Merged

Let Rust registrations override prelude definitions#121
shsms merged 1 commit into
mainfrom
rust-registration-overrides-prelude

Conversation

@shsms

@shsms shsms commented May 29, 2026

Copy link
Copy Markdown
Owner

A name first defined by a Lisp defun — notably the built-in prelude — registers its compiled-call dispatch in the compiler's vm_compilers.functions table and its CompiledDefun in bytecode.functions. compile_form consults that table before the symbol's global cell, but ctx.defun / defspecial / defmacro write only the global cell. So a direct call compiled on the VM path kept resolving to the prelude definition and the Rust override was silently shadowed — funcall/apply and the tree-walker already honored it, which made the asymmetry confusing.

Evict the stale compile-dispatch entry when a Rust function or macro is registered, so code compiled afterward resolves against the new global binding. The VM machine's own bytecode.functions is left intact, so the prelude's internal callers keep their pre-compiled binding.

A name first defined by a Lisp `defun` — notably the built-in prelude — registers its compiled-call dispatch in the compiler's `vm_compilers.functions` table and its `CompiledDefun` in `bytecode.functions`. `compile_form` consults that table before the symbol's global cell, but `ctx.defun` / `defspecial` / `defmacro` write only the global cell. So a direct call compiled on the VM path kept resolving to the prelude definition and the Rust override was silently shadowed — `funcall`/`apply` and the tree-walker already honored it, which made the asymmetry confusing.

Evict the stale compile-dispatch entry when a Rust function or macro is registered, so code compiled afterward resolves against the new global binding. The VM machine's own `bytecode.functions` is left intact, so the prelude's internal callers keep their pre-compiled binding.
@shsms
shsms merged commit 15ddd23 into main May 29, 2026
2 checks passed
@shsms
shsms deleted the rust-registration-overrides-prelude branch May 29, 2026 21:10
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