]> granicus.if.org Git - php/commitdiff
Forbid use() of auto-globals
authorNikita Popov <nikic@php.net>
Tue, 29 Dec 2015 10:20:44 +0000 (11:20 +0100)
committerNikita Popov <nikic@php.net>
Tue, 29 Dec 2015 10:20:44 +0000 (11:20 +0100)
We don't correctly support it, it doesn't make sense and it's also
forbidden for parameters.

Zend/zend_compile.c

index 97be4b966ea7aa471de9d503d822c777474d54b0..3a7e0b552cdce885ed9d71941b9b5125b4f867b5 100644 (file)
@@ -4908,6 +4908,10 @@ void zend_compile_closure_uses(zend_ast *ast) /* {{{ */
                        zend_error_noreturn(E_COMPILE_ERROR, "Cannot use $this as lexical variable");
                }
 
+               if (zend_is_auto_global(name)) {
+                       zend_error_noreturn(E_COMPILE_ERROR, "Cannot use auto-global as lexical variable");
+               }
+
                ZVAL_NULL(&zv);
                Z_CONST_FLAGS(zv) = by_ref ? IS_LEXICAL_REF : IS_LEXICAL_VAR;