From cf2cc717979df6afb4685cb5eaac43fcab5e8b2c Mon Sep 17 00:00:00 2001 From: Dmitrii Derepko Date: Thu, 30 Jan 2025 19:51:37 +0300 Subject: [PATCH 1/2] test: add unexpected allowed expression position showcase --- Zend/tests/throw/001.phpt | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Zend/tests/throw/001.phpt b/Zend/tests/throw/001.phpt index ba2406c6d3887..b83192e7b6a48 100644 --- a/Zend/tests/throw/001.phpt +++ b/Zend/tests/throw/001.phpt @@ -147,6 +147,22 @@ try { var_dump($e->getMessage()); } +try { + (function () { + return "string" + throw null ?? throw new Exception('return throw null ?? throw new Exception();'); + })(); +} catch (Exception $e) { + var_dump($e->getMessage()); +} + +try { + (function () { + return "string1" . 5 . "ok" / throw throw throw throw new Exception("cool"); + })(); +} catch (Exception $e) { + var_dump($e->getMessage()); +} + ?> --EXPECT-- string(13) "true && throw" @@ -171,3 +187,5 @@ string(42) "Unsupported operand types: Exception + int" string(35) "throw $exception = new Exception();" string(37) "throw $exception ??= new Exception();" string(30) "throw null ?? new Exception();" +string(43) "return throw null ?? throw new Exception();" +string(43) "cool" From 0767fe50e69a9094f65b55baf150a6b7d2e1e59a Mon Sep 17 00:00:00 2001 From: Dmitrii Derepko Date: Thu, 30 Jan 2025 20:26:54 +0300 Subject: [PATCH 2/2] fix test --- Zend/tests/throw/001.phpt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Zend/tests/throw/001.phpt b/Zend/tests/throw/001.phpt index b83192e7b6a48..21766ea890db7 100644 --- a/Zend/tests/throw/001.phpt +++ b/Zend/tests/throw/001.phpt @@ -188,4 +188,4 @@ string(35) "throw $exception = new Exception();" string(37) "throw $exception ??= new Exception();" string(30) "throw null ?? new Exception();" string(43) "return throw null ?? throw new Exception();" -string(43) "cool" +string(4) "cool"