[php-src] PR #25781: Fix GH-25756: Do not fold IS_VAR QM_ASSIGN into ZEND_RETURN

From: Date: Thu, 26 Nov 2026 12:30:04 +0000
Subject: [php-src] PR #25781: Fix GH-25756: Do not fold IS_VAR QM_ASSIGN into ZEND_RETURN
Groups: php.git-pulls 
Request: Send a blank email to git-pulls+get-41046@lists.php.net to get a copy of this message
Pull Request: https://github.com/php/php-src/pull/25781 Author: prateekbhujel Since the VAR|TMP overhaul (GH-20628, 6173a9a1098), ZEND_RETURN only handles CONST|TMP|CV operands, and by-reference assignments (e.g. return $a = &$b;, arrow functions, match arms) emit ZEND_QM_ASSIGN to unwrap the IS_VAR reference into an IS_TMP_VAR. In Zend/Optimizer/block_pass.c, the ZEND_RETURN optimization folded T = QM_ASSIGN(X); RETURN(T) into RETURN(X) without checking src->op1_type != IS_VAR (unlike the ZEND_JMPZ/ZEND_JMPNZ and ZEND_JMPZ_EX/ZEND_JMPNZ_EX folds in the same pass), producing ZEND_RETURN with an IS_VAR operand (Fatal error: Invalid opcode 62/4/0). Audited all other COPY_NODE / ZEND_QM_ASSIGN folds in Zend/Optimizer/block_pass.c against the handlers changed in GH-20628; ZEND_RETURN is the only missing src->op1_type != IS_VAR guard. Closes GH-25756.

« previous php.git-pulls (#41046) next »