Let Rust registrations override prelude definitions - #121
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A name first defined by a Lisp
defun— notably the built-in prelude — registers its compiled-call dispatch in the compiler'svm_compilers.functionstable and itsCompiledDefuninbytecode.functions.compile_formconsults that table before the symbol's global cell, butctx.defun/defspecial/defmacrowrite 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/applyand 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.functionsis left intact, so the prelude's internal callers keep their pre-compiled binding.