php-src/Zend/tests/declare_006.phpt
Sara Golemon 868930e079 Fix potential crash when setting invalid declare value
Using a non-literal expression in a declare value can cause the
compiler to crash trying to turn that AST node into a usable zval.

There was an existing test for such values using 'encoding',
but that didn't crash because it's handled by the lexer
rather than being compiled.

Trying to use a non-literal with ticks reproduces the crash.
2017-02-28 17:08:23 -08:00

11 lines
231 B
PHP

--TEST--
Use of non-literals in declare ticks values crashes compiler
--FILE--
<?php
declare(ticks = UNKNOWN_CONST) {
echo 'Done';
}
--EXPECTF--
Fatal error: declare(ticks) value must be a literal in %sdeclare_006.php on line 2