cvs: ZendEngine2 / zend_compile.c /tests ns_039.phpt ns_040.phpt ns_059.phpt
| From: | Dmitry Stogov | Date: | Thu, 22 Nov 2007 10:46:44 +0000 |
| Subject: | cvs: ZendEngine2 / zend_compile.c /tests ns_039.phpt ns_040.phpt ns_059.phpt | ||
| Groups: | php.zend-engine.cvs | ||
| Request: | Send a blank email to php-zend-engine-cvs+get-6206@lists.php.net to get a copy of this message | ||
dmitry Thu Nov 22 10:46:44 2007 UTC
Modified files:
/ZendEngine2 zend_compile.c
/ZendEngine2/tests ns_059.phpt ns_039.phpt ns_040.phpt
Log:
Fixed bug #43318
The "const" statement is still allowed outside of namespaces but arrays are disabled.
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_compile.c?r1=1.786&r2=1.787&diff_format=u
Index: ZendEngine2/zend_compile.c
diff -u ZendEngine2/zend_compile.c:1.786 ZendEngine2/zend_compile.c:1.787
--- ZendEngine2/zend_compile.c:1.786 Thu Nov 22 09:03:11 2007
+++ ZendEngine2/zend_compile.c Thu Nov 22 10:46:44 2007
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_compile.c,v 1.786 2007/11/22 09:03:11 dmitry Exp $ */
+/* $Id: zend_compile.c,v 1.787 2007/11/22 10:46:44 dmitry Exp $ */
#include <zend_language_parser.h>
#include "zend.h"
@@ -5338,6 +5338,10 @@
{
zend_op *opline;
+ if(Z_TYPE(value->u.constant) == IS_CONSTANT_ARRAY) {
+ zend_error(E_COMPILE_ERROR, "Arrays are not allowed as constants");
+ }
+
if (zend_get_ct_const(&name->u.constant TSRMLS_CC)) {
zend_error(E_COMPILE_ERROR, "Cannot redeclare constant '%R'",
Z_TYPE(name->u.constant), Z_UNIVAL(name->u.constant));
}
http://cvs.php.net/viewvc.cgi/ZendEngine2/tests/ns_059.phpt?r1=1.1&r2=1.2&diff_format=u
Index: ZendEngine2/tests/ns_059.phpt
diff -u /dev/null ZendEngine2/tests/ns_059.phpt:1.2
--- /dev/null Thu Nov 22 10:46:44 2007
+++ ZendEngine2/tests/ns_059.phpt Thu Nov 22 10:46:44 2007
@@ -0,0 +1,8 @@
+--TEST--
+059: Constant arrays
+--FILE--
+<?php
+const C = array();
+--EXPECTF--
+Fatal error: Arrays are not allowed as constants in %sns_059.php on line 2
+
http://cvs.php.net/viewvc.cgi/ZendEngine2/tests/ns_039.phpt?r1=1.1&r2=1.2&diff_format=u
Index: ZendEngine2/tests/ns_039.phpt
diff -u ZendEngine2/tests/ns_039.phpt:1.1 ZendEngine2/tests/ns_039.phpt:1.2
--- ZendEngine2/tests/ns_039.phpt:1.1 Fri Aug 24 13:50:52 2007
+++ ZendEngine2/tests/ns_039.phpt Thu Nov 22 10:46:44 2007
@@ -2,22 +2,24 @@
039: Constant declaration
--FILE--
<?php
+function foo($a = A) {
+ echo "$a\n";
+}
+function bar($a = array(A => B)) {
+ foreach ($a as $key => $val) {
+ echo "$key\n";
+ echo "$val\n";
+ }
+}
const A = "ok";
const B = A;
-const C = array("ok");
-const D = array(B);
echo A . "\n";
echo B . "\n";
-print_r(C);
-print_r(D);
+foo();
+bar();
--EXPECT--
ok
ok
-Array
-(
- [0] => ok
-)
-Array
-(
- [0] => ok
-)
+ok
+ok
+ok
http://cvs.php.net/viewvc.cgi/ZendEngine2/tests/ns_040.phpt?r1=1.2&r2=1.3&diff_format=u
Index: ZendEngine2/tests/ns_040.phpt
diff -u ZendEngine2/tests/ns_040.phpt:1.2 ZendEngine2/tests/ns_040.phpt:1.3
--- ZendEngine2/tests/ns_040.phpt:1.2 Tue Nov 6 07:29:41 2007
+++ ZendEngine2/tests/ns_040.phpt Thu Nov 22 10:46:44 2007
@@ -6,9 +6,6 @@
use X as Y;
const A = "ok\n";
const B = A;
-const C = array(A);
-const D = array("aaa"=>A);
-const E = array(A=>"aaa\n");
function f1($x=A) {
echo $x;
}
@@ -42,9 +39,6 @@
f3();
f4();
echo B;
-$x = C; echo $x[0];
-$x = D; echo $x["aaa"];
-$x = E; echo $x["ok\n"];
f5();
f6();
f7();
@@ -61,8 +55,5 @@
ok
ok
ok
-aaa
-ok
-ok
ok
aaa