Skip to content

Commit dabbfe7

Browse files
ondrejmirtesclaude
andcommitted
Reset NodeCallbackScope ask memos when cloning scopes natively
The native scopeWith() derives scopes by cloning and resetting per-instance memo properties to their fresh-constructor defaults - the PHP twin's duplicateWith() constructs a fresh scope instead, so any memo the reset list misses survives cloning only under turbo. NodeCallbackScope's list was stale twice over: truthyValueExprs and falseyValueExprs no longer exist (replaced by the ordered scopeOps list), and the askedTypes/askedNativeTypes ask memos were never listed - a rule that asked a node's type, derived a scope (assignExpression(), filterByTruthyValue(), ...), and asked again read the pre-derivation answer back from the cloned memo instead of replaying the recorded ops. NodeCallbackScopeDerivedOpsRuleTest caught it on every turbo CI job. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GnwgpaeUXRkgSDyg95tfK8
1 parent 37a4aee commit dabbfe7

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

‎turbo-ext/src/ScopeOps.cpp‎

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,9 @@ typedef struct _pt_scope_offsets {
3838
int32_t scope_out_of_first_level;
3939
int32_t scope_with_promoted_native;
4040
int32_t walk_scope; /* NodeCallbackScope */
41-
int32_t truthy_value_exprs; /* NodeCallbackScope */
42-
int32_t falsey_value_exprs; /* NodeCallbackScope */
41+
int32_t scope_ops; /* NodeCallbackScope */
42+
int32_t asked_types; /* NodeCallbackScope */
43+
int32_t asked_native_types; /* NodeCallbackScope */
4344
} pt_scope_offsets;
4445

4546
static HashTable pt_scope_offsets_cache;
@@ -79,8 +80,9 @@ static pt_scope_offsets *pt_scope_offsets_for(zend_class_entry *ce)
7980
off->scope_out_of_first_level = pt_instance_prop_offset(ce, "scopeOutOfFirstLevelStatement", sizeof("scopeOutOfFirstLevelStatement") - 1);
8081
off->scope_with_promoted_native = pt_instance_prop_offset(ce, "scopeWithPromotedNativeTypes", sizeof("scopeWithPromotedNativeTypes") - 1);
8182
off->walk_scope = pt_instance_prop_offset(ce, "walkScope", sizeof("walkScope") - 1);
82-
off->truthy_value_exprs = pt_instance_prop_offset(ce, "truthyValueExprs", sizeof("truthyValueExprs") - 1);
83-
off->falsey_value_exprs = pt_instance_prop_offset(ce, "falseyValueExprs", sizeof("falseyValueExprs") - 1);
83+
off->scope_ops = pt_instance_prop_offset(ce, "scopeOps", sizeof("scopeOps") - 1);
84+
off->asked_types = pt_instance_prop_offset(ce, "askedTypes", sizeof("askedTypes") - 1);
85+
off->asked_native_types = pt_instance_prop_offset(ce, "askedNativeTypes", sizeof("askedNativeTypes") - 1);
8486

8587
zend_hash_add_ptr(&pt_scope_offsets_cache, ce->name, off);
8688
return off;
@@ -303,8 +305,9 @@ class ScopeOps
303305
resetToNull(cloneObj, off->scope_out_of_first_level);
304306
resetToNull(cloneObj, off->scope_with_promoted_native);
305307
resetToNull(cloneObj, off->walk_scope);
306-
resetToEmptyArray(cloneObj, off->truthy_value_exprs);
307-
resetToEmptyArray(cloneObj, off->falsey_value_exprs);
308+
resetToEmptyArray(cloneObj, off->scope_ops);
309+
resetToEmptyArray(cloneObj, off->asked_types);
310+
resetToEmptyArray(cloneObj, off->asked_native_types);
308311

309312
zval out;
310313
ZVAL_OBJ(&out, clone);

0 commit comments

Comments
 (0)