Language: ArrayAccess $obj[$k] += n uses live offsetGet value (#31947) - #31976
Merged
Merged
Conversation
ZEND_ASSIGN_DIM_OP was TypeErroring mixed + int because the writable ArrayAccess view was used as the numeric operand. Unwrap offsetGet, then write back through offsetSet, matching ++. Co-authored-by: Cursor <cursoragent@cursor.com>
4 tasks
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.
Summary
$obj[$k] += n/*=on a userArrayAccesswith by-refoffsetGetTypeErroredmixed + intbecauseTYPE_ARRAYACCESS_OFFSETwas used as the numeric operand.offsetGetpayload (ZendZEND_ASSIGN_DIM_OP/zend_std_read_dimensionBP_VAR_RW) and writes the result back throughoffsetSet, matching postfix++.lib/VM/Variable.php(numericOp/bitwiseOp/incDecOp),lib/VM/ArrayAccessDimension.php(read()). php-src:Zend/zend_vm_def.h,Zend/zend_interfaces.c,Zend/zend_object_handlers.c. No newruntime/*.c.Test plan
inc=2/plus=3/mul=3./script/phpunit.sh --filter ArrayAccessAssignOp31947VMTest./script/phpunit.sh --filter ArrayAccessAssignOp31947JITTestVerification
Not covered: full
VMTest/JITTestsuites,script/differential-sweep.sh, AOT native emit,ci-local.sh.Made with Cursor