Skip to content

Fix invalid returned opcode for memoized expressions #12345

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Zend/tests/assign_coalesce_009.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
--TEST--
Invalid opcode returned from zend_compile_var_inner() for memoized expression
--FILE--
<?php
strlen("foo")[0] ??= 123;
?>
--EXPECTF--
Fatal error: Cannot use result of built-in function in write context in %s on line %d
3 changes: 2 additions & 1 deletion Zend/zend_compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -10616,7 +10616,8 @@ static zend_op *zend_compile_var_inner(znode *result, zend_ast *ast, uint32_t ty
case ZEND_AST_NULLSAFE_METHOD_CALL:
case ZEND_AST_STATIC_CALL:
zend_compile_memoized_expr(result, ast);
return &CG(active_op_array)->opcodes[CG(active_op_array)->last - 1];
/* This might not actually produce an opcode, e.g. for expressions evaluated at comptime. */
return NULL;
}
}

Expand Down