Repository navigation
Fix: An ArrayParam function that can run user code stays interpreted (#203) - #205
Merged
Merged
Conversation
This was referenced Oct 17, 2026
Closed
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.
Closes #203
Defect fixed: a function holding a list copy-in that also ran user code compiled, and diverged from CPython. On develop,
f(xs, cb)(cb()setsxs[0] = 100.0, thenreturn xs[0]) returned 1.0 compiled against 100.0 interpreted. A store followed by a callback was also overwritten by write-back.Fix: a new verifier rule,
verify/array-open. A function with an ArrayParam must be closed: no GetAttr, CallObject, Truth, CompareObj, ObjToFloat or OBJ BinOp. It also may not use FieldGet or New, whose slow paths run user code after a class change. The rule applies over the whole call tree (fixpoint). Such a function stays interpreted with a reason.Tests added:
test_array_function_with_a_callback_matches_cpython.Red before the fix: 5 failed, 1 passed; the passing one is the accepted closed case.
Tests corrected: these encoded the defect and now use closed array functions or non-array functions:
test_len_bound_is_zero_to_two_to_the_62;test_the_same_open_node_without_entry_globals_is_accepted;scaleandipbase functions;scalehad an ArrayParam;fillintest_cgen_class_changes.py. It was an array function whose slot read ran a property installed after init, which is exactly this defect. It now returns the entry global instead, so the scenario still checks the snapshot against the property.Documentation corrected: the ArrayParam contract in
ir.py(the verifier, not the front end, enforces it), and the SPEC N-9 table row.Verification (local):