summaryrefslogtreecommitdiff
path: root/Zend
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2020-10-30 15:48:03 +0100
committerNikita Popov <nikita.ppv@gmail.com>2020-10-30 15:52:10 +0100
commit83738281eb9f2577eda1c76a6acfe644d6fcc6c1 (patch)
tree6623a722224a3053010b090f5b62d0abff88206f /Zend
parent0427dcb91300f993b80c3d77f348d5e1ffcb0d16 (diff)
downloadphp-git-83738281eb9f2577eda1c76a6acfe644d6fcc6c1.tar.gz
Fix SSA integrity violation for type inference in dead code
The foreach body can never be executed and thus may contain empty types. We should still uphold our SSA integrity invariants in that case.
Diffstat (limited to 'Zend')
-rw-r--r--Zend/tests/dead_array_type_inference.phpt18
1 files changed, 18 insertions, 0 deletions
diff --git a/Zend/tests/dead_array_type_inference.phpt b/Zend/tests/dead_array_type_inference.phpt
new file mode 100644
index 0000000000..51f9b05816
--- /dev/null
+++ b/Zend/tests/dead_array_type_inference.phpt
@@ -0,0 +1,18 @@
+--TEST--
+Make sure type inference upholds invariants for dead arrays
+--FILE--
+<?php
+
+function test() {
+ foreach ($a as $v) {
+ $b[] = $v;
+ }
+}
+
+test();
+
+?>
+--EXPECTF--
+Notice: Undefined variable: a in %s on line %d
+
+Warning: Invalid argument supplied for foreach() in %s on line %d