Skip to content

Commit fd4c061

Browse files
committed
Align error messages between normal VM and JIT for RW when using object as object
1 parent 9d05a77 commit fd4c061

File tree

3 files changed

+4
-6
lines changed

3 files changed

+4
-6
lines changed

Zend/tests/offsets/objects/const_dimension/object_offset_behaviour.phpt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
--TEST--
22
Object offset behaviour
3-
--XFAIL--
4-
JIT and normal VM don't agree on error message for RW
53
--FILE--
64
<?php
75

Zend/tests/offsets/objects/expect.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Cannot use object of type stdClass as array
55
Read:
66
Cannot use object of type stdClass as array
77
Read-Write:
8-
Cannot use object as array
8+
Cannot use object of type stdClass as array
99
isset():
1010
Cannot use object of type stdClass as array
1111
empty():

Zend/zend_execute.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1504,9 +1504,9 @@ ZEND_API bool zend_never_inline zend_verify_class_constant_type(zend_class_const
15041504
return 1;
15051505
}
15061506

1507-
static zend_never_inline ZEND_COLD void ZEND_FASTCALL zend_use_object_as_array(void)
1507+
static zend_never_inline ZEND_COLD void ZEND_FASTCALL zend_use_object_as_array(const zend_object *object)
15081508
{
1509-
zend_throw_error(NULL, "Cannot use object as array");
1509+
zend_throw_error(NULL, "Cannot use object of type %s as array", ZSTR_VAL(object->ce->name));
15101510
}
15111511

15121512
static zend_never_inline ZEND_COLD void ZEND_FASTCALL zend_illegal_array_offset_access(const zval *offset)
@@ -1584,7 +1584,7 @@ static zend_never_inline void zend_binary_assign_op_obj_dim(zend_object *obj, zv
15841584
}
15851585
zval_ptr_dtor(&res);
15861586
} else {
1587-
zend_use_object_as_array();
1587+
zend_use_object_as_array(obj);
15881588
if (UNEXPECTED(RETURN_VALUE_USED(opline))) {
15891589
ZVAL_NULL(EX_VAR(opline->result.var));
15901590
}

0 commit comments

Comments
 (0)