Skip to content

Commit df9330c

Browse files
committed
Fix range live var
1 parent 9412d5a commit df9330c

File tree

2 files changed

+37
-17
lines changed

2 files changed

+37
-17
lines changed

Zend/tests/match/bugs/011.phpt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
--TEST--
2+
WIP
3+
--FILE--
4+
<?php
5+
6+
function test() {
7+
do {
8+
$foo = 'Hello';
9+
$bar = 'world';
10+
var_dump("$foo ${null ?? { 'bar' }}");
11+
var_dump("$foo ${null ?? { break; 'bar' }}");
12+
} while (0);
13+
}
14+
15+
test();
16+
17+
?>
18+
--EXPECTF--
19+
Deprecated: Using ${expr} (variable variables) in strings is deprecated, use {${expr}} instead in %s on line %d
20+
21+
Deprecated: Using ${expr} (variable variables) in strings is deprecated, use {${expr}} instead in %s on line %d
22+
string(11) "Hello world"

Zend/zend_execute.c

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4817,23 +4817,21 @@ static void cleanup_live_vars_range(zend_execute_data *execute_data, uint32_t ra
48174817
}
48184818
zval_ptr_dtor_nogc(var);
48194819
} else if (kind == ZEND_LIVE_ROPE) {
4820-
// Not sure about op_num...
4821-
ZEND_UNREACHABLE();
4822-
// zend_string **rope = (zend_string **)var;
4823-
// zend_op *last = EX(func)->op_array.opcodes + op_num;
4824-
// while ((last->opcode != ZEND_ROPE_ADD && last->opcode != ZEND_ROPE_INIT)
4825-
// || last->result.var != var_num) {
4826-
// ZEND_ASSERT(last >= EX(func)->op_array.opcodes);
4827-
// last--;
4828-
// }
4829-
// if (last->opcode == ZEND_ROPE_INIT) {
4830-
// zend_string_release_ex(*rope, 0);
4831-
// } else {
4832-
// int j = last->extended_value;
4833-
// do {
4834-
// zend_string_release_ex(rope[j], 0);
4835-
// } while (j--);
4836-
// }
4820+
zend_string **rope = (zend_string **)var;
4821+
zend_op *last = EX(func)->op_array.opcodes + range_end;
4822+
while ((last->opcode != ZEND_ROPE_ADD && last->opcode != ZEND_ROPE_INIT)
4823+
|| last->result.var != var_num) {
4824+
ZEND_ASSERT(last >= EX(func)->op_array.opcodes);
4825+
last--;
4826+
}
4827+
if (last->opcode == ZEND_ROPE_INIT) {
4828+
zend_string_release_ex(*rope, 0);
4829+
} else {
4830+
int j = last->extended_value;
4831+
do {
4832+
zend_string_release_ex(rope[j], 0);
4833+
} while (j--);
4834+
}
48374835
} else if (kind == ZEND_LIVE_SILENCE) {
48384836
/* restore previous error_reporting value */
48394837
if (E_HAS_ONLY_FATAL_ERRORS(EG(error_reporting))

0 commit comments

Comments
 (0)