summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2020-04-01 10:05:26 +0200
committerNikita Popov <nikita.ppv@gmail.com>2020-04-01 11:26:43 +0200
commitcdaf35033d29cdccbe8933afaa9f507b5c3176b6 (patch)
tree23188bd41e6701709ea435528934cc4c766a4cf1
parent9c0afc859c9c678e6aaaed85ace6d11a1a0a2c5b (diff)
downloadphp-git-cdaf35033d29cdccbe8933afaa9f507b5c3176b6.tar.gz
Improve "unsupported operands" error
By mentioning the operand types. We can do that now, as the original operand types now remain available. Closes GH-5330.
-rw-r--r--Zend/tests/add_002.phpt4
-rw-r--r--Zend/tests/add_003.phpt4
-rw-r--r--Zend/tests/add_004.phpt4
-rw-r--r--Zend/tests/add_007.phpt4
-rw-r--r--Zend/tests/bug74084.phpt8
-rw-r--r--Zend/tests/constant_expressions_exceptions_001.phpt7
-rw-r--r--Zend/tests/constant_expressions_exceptions_002.phpt3
-rw-r--r--Zend/tests/div_002.phpt4
-rw-r--r--Zend/tests/mul_001.phpt4
-rw-r--r--Zend/tests/pow_array_leak.phpt4
-rw-r--r--Zend/tests/runtime_compile_time_binary_operands.phpt7
-rw-r--r--Zend/tests/sub_001.phpt4
-rw-r--r--Zend/zend_operators.c30
-rw-r--r--ext/standard/tests/math/pow_variation1.phpt2
-rw-r--r--ext/standard/tests/math/pow_variation1_64bit.phpt2
-rw-r--r--ext/standard/tests/math/pow_variation2.phpt2
16 files changed, 50 insertions, 43 deletions
diff --git a/Zend/tests/add_002.phpt b/Zend/tests/add_002.phpt
index da99499864..131569d856 100644
--- a/Zend/tests/add_002.phpt
+++ b/Zend/tests/add_002.phpt
@@ -20,9 +20,9 @@ var_dump($c);
echo "Done\n";
?>
--EXPECTF--
-Exception: Unsupported operand types
+Exception: Unsupported operand types: array + object
-Fatal error: Uncaught Error: Unsupported operand types in %s:%d
+Fatal error: Uncaught TypeError: Unsupported operand types: array + object in %s:%d
Stack trace:
#0 {main}
thrown in %s on line %d
diff --git a/Zend/tests/add_003.phpt b/Zend/tests/add_003.phpt
index b70ff022ec..0f03f550e0 100644
--- a/Zend/tests/add_003.phpt
+++ b/Zend/tests/add_003.phpt
@@ -22,11 +22,11 @@ echo "Done\n";
--EXPECTF--
Notice: Object of class stdClass could not be converted to number in %sadd_003.php on line %d
-Exception: Unsupported operand types
+Exception: Unsupported operand types: object + array
Notice: Object of class stdClass could not be converted to number in %s on line %d
-Fatal error: Uncaught Error: Unsupported operand types in %s:%d
+Fatal error: Uncaught TypeError: Unsupported operand types: object + array in %s:%d
Stack trace:
#0 {main}
thrown in %s on line %d
diff --git a/Zend/tests/add_004.phpt b/Zend/tests/add_004.phpt
index 161c4c2b39..2f16f10eaf 100644
--- a/Zend/tests/add_004.phpt
+++ b/Zend/tests/add_004.phpt
@@ -17,9 +17,9 @@ var_dump($c);
echo "Done\n";
?>
--EXPECTF--
-Exception: Unsupported operand types
+Exception: Unsupported operand types: array + int
-Fatal error: Uncaught Error: Unsupported operand types in %s:%d
+Fatal error: Uncaught TypeError: Unsupported operand types: array + int in %s:%d
Stack trace:
#0 {main}
thrown in %s on line %d
diff --git a/Zend/tests/add_007.phpt b/Zend/tests/add_007.phpt
index e7e0de79ba..a2beddfaed 100644
--- a/Zend/tests/add_007.phpt
+++ b/Zend/tests/add_007.phpt
@@ -19,9 +19,9 @@ var_dump($c);
echo "Done\n";
?>
--EXPECTF--
-Exception: Unsupported operand types
+Exception: Unsupported operand types: array + string
-Fatal error: Uncaught Error: Unsupported operand types in %s:%d
+Fatal error: Uncaught TypeError: Unsupported operand types: array + string in %s:%d
Stack trace:
#0 {main}
thrown in %s on line %d
diff --git a/Zend/tests/bug74084.phpt b/Zend/tests/bug74084.phpt
index ab4dce0a5a..36239438c6 100644
--- a/Zend/tests/bug74084.phpt
+++ b/Zend/tests/bug74084.phpt
@@ -31,7 +31,7 @@ try {
}
?>
--EXPECT--
-Unsupported operand types
-Unsupported operand types
-Unsupported operand types
-Unsupported operand types
+Unsupported operand types: array - array
+Unsupported operand types: array * array
+Unsupported operand types: array / array
+Unsupported operand types: array ** array
diff --git a/Zend/tests/constant_expressions_exceptions_001.phpt b/Zend/tests/constant_expressions_exceptions_001.phpt
index 076584a569..6a111d3aed 100644
--- a/Zend/tests/constant_expressions_exceptions_001.phpt
+++ b/Zend/tests/constant_expressions_exceptions_001.phpt
@@ -3,5 +3,8 @@ Constant Expressions with unsupported operands 001
--FILE--
<?php
const T = array(1,2) - array(0);
---EXPECTF--
-Fatal error: Unsupported operand types in %sconstant_expressions_exceptions_001.php on line 2
+--EXPECT--
+Fatal error: Uncaught TypeError: Unsupported operand types: array - array in [no active file]:0
+Stack trace:
+#0 {main}
+ thrown in [no active file] on line 0
diff --git a/Zend/tests/constant_expressions_exceptions_002.phpt b/Zend/tests/constant_expressions_exceptions_002.phpt
index c10bd10843..88c20f10cf 100644
--- a/Zend/tests/constant_expressions_exceptions_002.phpt
+++ b/Zend/tests/constant_expressions_exceptions_002.phpt
@@ -10,4 +10,5 @@ try {
?>
DONE
--EXPECTF--
-Fatal error: Unsupported operand types in %sconstant_expressions_exceptions.inc on line 2
+Exception: Unsupported operand types: array - array in %s on line %d
+DONE
diff --git a/Zend/tests/div_002.phpt b/Zend/tests/div_002.phpt
index 1fc006def5..22ed3f1393 100644
--- a/Zend/tests/div_002.phpt
+++ b/Zend/tests/div_002.phpt
@@ -18,9 +18,9 @@ var_dump($c);
echo "Done\n";
?>
--EXPECTF--
-Exception: Unsupported operand types
+Exception: Unsupported operand types: array / array
-Fatal error: Uncaught Error: Unsupported operand types in %s:%d
+Fatal error: Uncaught TypeError: Unsupported operand types: array / array in %s:%d
Stack trace:
#0 {main}
thrown in %s on line %d
diff --git a/Zend/tests/mul_001.phpt b/Zend/tests/mul_001.phpt
index b57c61776c..ddb6576853 100644
--- a/Zend/tests/mul_001.phpt
+++ b/Zend/tests/mul_001.phpt
@@ -18,9 +18,9 @@ var_dump($c);
echo "Done\n";
?>
--EXPECTF--
-Exception: Unsupported operand types
+Exception: Unsupported operand types: array * array
-Fatal error: Uncaught Error: Unsupported operand types in %s:%d
+Fatal error: Uncaught TypeError: Unsupported operand types: array * array in %s:%d
Stack trace:
#0 {main}
thrown in %s on line %d
diff --git a/Zend/tests/pow_array_leak.phpt b/Zend/tests/pow_array_leak.phpt
index a17a290458..06dce0ac6a 100644
--- a/Zend/tests/pow_array_leak.phpt
+++ b/Zend/tests/pow_array_leak.phpt
@@ -21,12 +21,12 @@ var_dump($x);
?>
--EXPECT--
-Unsupported operand types
+Unsupported operand types: array ** int
array(1) {
[0]=>
int(0)
}
-Unsupported operand types
+Unsupported operand types: array ** array
array(1) {
[0]=>
int(0)
diff --git a/Zend/tests/runtime_compile_time_binary_operands.phpt b/Zend/tests/runtime_compile_time_binary_operands.phpt
index 8c15a9658f..1a1409c2bb 100644
--- a/Zend/tests/runtime_compile_time_binary_operands.phpt
+++ b/Zend/tests/runtime_compile_time_binary_operands.phpt
@@ -153,5 +153,8 @@ if($c === 0) {
$fl = __DIR__ . DIRECTORY_SEPARATOR . 'compare_binary_operands_temp.php';
@unlink($fl);
?>
---EXPECT--
-Failed: 0
+--EXPECTF--
+Fatal error: Uncaught TypeError: Unsupported operand types: int + array in %s:%d
+Stack trace:
+#0 {main}
+ thrown in %s on line %d
diff --git a/Zend/tests/sub_001.phpt b/Zend/tests/sub_001.phpt
index 165c64153b..92e3ff0021 100644
--- a/Zend/tests/sub_001.phpt
+++ b/Zend/tests/sub_001.phpt
@@ -18,9 +18,9 @@ var_dump($c);
echo "Done\n";
?>
--EXPECTF--
-Exception: Unsupported operand types
+Exception: Unsupported operand types: array - array
-Fatal error: Uncaught Error: Unsupported operand types in %s:%d
+Fatal error: Uncaught TypeError: Unsupported operand types: array - array in %s:%d
Stack trace:
#0 {main}
thrown in %s on line %d
diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c
index f3751ecb0d..b4be563bac 100644
--- a/Zend/zend_operators.c
+++ b/Zend/zend_operators.c
@@ -939,6 +939,16 @@ ZEND_API zend_string* ZEND_FASTCALL zval_try_get_string_func(zval *op) /* {{{ */
}
/* }}} */
+static ZEND_COLD zend_never_inline void ZEND_FASTCALL zend_binop_error(
+ const char *operator, zval *op1, zval *op2) {
+ if (EG(exception)) {
+ return;
+ }
+
+ zend_type_error("Unsupported operand types: %s %s %s",
+ zend_get_type_by_const(Z_TYPE_P(op1)), operator, zend_get_type_by_const(Z_TYPE_P(op2)));
+}
+
static zend_never_inline void ZEND_FASTCALL add_function_array(zval *result, zval *op1, zval *op2) /* {{{ */
{
if ((result == op1) && (result == op2)) {
@@ -991,9 +1001,7 @@ static zend_never_inline int ZEND_FASTCALL add_function_slow(zval *result, zval
zval op1_copy, op2_copy;
if (UNEXPECTED(zendi_try_convert_scalar_to_number(op1, &op1_copy) == FAILURE)
|| UNEXPECTED(zendi_try_convert_scalar_to_number(op2, &op2_copy) == FAILURE)) {
- if (!EG(exception)) {
- zend_throw_error(NULL, "Unsupported operand types");
- }
+ zend_binop_error("+", op1, op2);
if (result != op1) {
ZVAL_UNDEF(result);
}
@@ -1056,9 +1064,7 @@ static zend_never_inline int ZEND_FASTCALL sub_function_slow(zval *result, zval
zval op1_copy, op2_copy;
if (UNEXPECTED(zendi_try_convert_scalar_to_number(op1, &op1_copy) == FAILURE)
|| UNEXPECTED(zendi_try_convert_scalar_to_number(op2, &op2_copy) == FAILURE)) {
- if (!EG(exception)) {
- zend_throw_error(NULL, "Unsupported operand types");
- }
+ zend_binop_error("-", op1, op2);
if (result != op1) {
ZVAL_UNDEF(result);
}
@@ -1125,9 +1131,7 @@ static zend_never_inline int ZEND_FASTCALL mul_function_slow(zval *result, zval
zval op1_copy, op2_copy;
if (UNEXPECTED(zendi_try_convert_scalar_to_number(op1, &op1_copy) == FAILURE)
|| UNEXPECTED(zendi_try_convert_scalar_to_number(op2, &op2_copy) == FAILURE)) {
- if (!EG(exception)) {
- zend_throw_error(NULL, "Unsupported operand types");
- }
+ zend_binop_error("*", op1, op2);
if (result != op1) {
ZVAL_UNDEF(result);
}
@@ -1226,9 +1230,7 @@ ZEND_API int ZEND_FASTCALL pow_function(zval *result, zval *op1, zval *op2) /* {
zval op1_copy, op2_copy;
if (UNEXPECTED(zendi_try_convert_scalar_to_number(op1, &op1_copy) == FAILURE)
|| UNEXPECTED(zendi_try_convert_scalar_to_number(op2, &op2_copy) == FAILURE)) {
- if (!EG(exception)) {
- zend_throw_error(NULL, "Unsupported operand types");
- }
+ zend_binop_error("**", op1, op2);
if (result != op1) {
ZVAL_UNDEF(result);
}
@@ -1306,9 +1308,7 @@ ZEND_API int ZEND_FASTCALL div_function(zval *result, zval *op1, zval *op2) /* {
zval op1_copy, op2_copy;
if (UNEXPECTED(zendi_try_convert_scalar_to_number(op1, &op1_copy) == FAILURE)
|| UNEXPECTED(zendi_try_convert_scalar_to_number(op2, &op2_copy) == FAILURE)) {
- if (!EG(exception)) {
- zend_throw_error(NULL, "Unsupported operand types");
- }
+ zend_binop_error("/", op1, op2);
if (result != op1) {
ZVAL_UNDEF(result);
}
diff --git a/ext/standard/tests/math/pow_variation1.phpt b/ext/standard/tests/math/pow_variation1.phpt
index 9c5bd06272..fc2c9aa1a2 100644
--- a/ext/standard/tests/math/pow_variation1.phpt
+++ b/ext/standard/tests/math/pow_variation1.phpt
@@ -156,7 +156,7 @@ Warning: A non-numeric value encountered in %s on line %d
int(0)
-- Iteration 19 --
-Unsupported operand types
+Unsupported operand types: array ** int
-- Iteration 20 --
diff --git a/ext/standard/tests/math/pow_variation1_64bit.phpt b/ext/standard/tests/math/pow_variation1_64bit.phpt
index c8a9509bb7..75b9f576db 100644
--- a/ext/standard/tests/math/pow_variation1_64bit.phpt
+++ b/ext/standard/tests/math/pow_variation1_64bit.phpt
@@ -156,7 +156,7 @@ Warning: A non-numeric value encountered in %s on line %d
int(0)
-- Iteration 19 --
-Unsupported operand types
+Unsupported operand types: array ** int
-- Iteration 20 --
diff --git a/ext/standard/tests/math/pow_variation2.phpt b/ext/standard/tests/math/pow_variation2.phpt
index de17e5fec7..8af96ef8d6 100644
--- a/ext/standard/tests/math/pow_variation2.phpt
+++ b/ext/standard/tests/math/pow_variation2.phpt
@@ -152,7 +152,7 @@ Warning: A non-numeric value encountered in %s on line %d
float(1)
-- Iteration 19 --
-Unsupported operand types
+Unsupported operand types: float ** array
-- Iteration 20 --