From: Nikita Popov Date: Tue, 29 Dec 2015 10:20:44 +0000 (+0100) Subject: Forbid use() of auto-globals X-Git-Tag: php-7.1.0alpha1~617^2~129 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4440436821404ff3c76682726e63d1aaf381f73a;p=php Forbid use() of auto-globals We don't correctly support it, it doesn't make sense and it's also forbidden for parameters. --- diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 97be4b966e..3a7e0b552c 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -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;