fix interactions with global names, function scopes & repl#469
Conversation
Merging this PR will not alter performance
Comparing Footnotes
|
Codecov Results 📊❌ Patch coverage is 68.98%. Project has 24136 uncovered lines. Files with missing lines (5)
Coverage diff@@ Coverage Diff @@
## main #PR +/-##
==========================================
- Coverage 66.19% 66.16% -0.03%
==========================================
Files 279 279 —
Lines 71052 71319 +267
Branches 152853 153176 +323
==========================================
+ Hits 47030 47183 +153
- Misses 24022 24136 +114
- Partials 3993 4028 +35Generated by Codecov Action |
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
1 issue found
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="crates/monty/src/intern.rs">
<violation number="1" location="crates/monty/src/intern.rs:913">
P1: New serialized field `global_slots` is missing `#[serde(default)]`, which breaks deserialization of previously dumped runners/snapshots.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
There was a problem hiding this comment.
1 issue found
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
There was a problem hiding this comment.
2 issues found
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
Fixes #183
I will probably extend this to also cover #423
Summary by cubic
Reworks global name resolution to be slot-safe and Python-correct without adding opcodes. Prepare eagerly allocates module slots for all global references; the VM falls back to builtins when a slot is
Undefined, andNameLookupalways caches into the correct slot. Fixes OOB panics, module-scope NameError semantics, and late binding in functions and the REPL.Refactors
Global; prepare allocates/reuses a real module slot for every global reference (including unresolved).LoadLocalCallable; callable loads useLoadGlobalCallable. Legacy opcodes remain for decode compatibility.LoadGlobalandLoadGlobalCallable;deletenow raisesNameErrorwhen the slot isUndefined.NameLookupalways carries a real slot; resume caches the value into that slot (globals or frame locals).Bug Fixes
global Xinside functions whenXhad no prior module slot.NameError(neverUnboundLocalError) and respect non-executed assignments.defshadows builtins for both callable and non-callable loads.Written for commit 607fe80. Summary will update on new commits.
Review in cubic