Allow non-static expressions in function parameter defaults
commitf4e68f903471f106d803d597c9dfa8c07c44297b
authorSara Golemon <sgolemon@fb.com>
Sat, 15 Nov 2014 22:15:20 +0000 (15 14:15 -0800)
committerhhvm-bot <hhvm-bot@fb.com>
Sat, 15 Nov 2014 22:30:30 +0000 (15 14:30 -0800)
treebc24f2871659bc696831683d9a9accfcede7cf5a
parentb0a7c118d0585b6c769a7b8211694ee20d870c60
Allow non-static expressions in function parameter defaults

Summary: This is primarily for HNI expressions such as the following
in datetime:

  function date(string $format, int $now = TimeStamp::Current());

HHVM compiles default arguments to Bytecode and jumps to the correct
location in the function for initialization anyway, so there's no real
need to limit the default to static expressions apart from PHP's
language design.

Closes #2886

Reviewed By: @paulbiss

Differential Revision: D1682957

Signature: t1:1682957:1416007027:42343f4baf80906e22308e1e1e91bea7027967d1
22 files changed:
hphp/parser/hphp.tab.cpp
hphp/parser/hphp.y
hphp/test/slow/function/anonymous-default.php [new file with mode: 0644]
hphp/test/slow/function/anonymous-default.php.expect [new file with mode: 0644]
hphp/test/slow/function/closure-default.php [new file with mode: 0644]
hphp/test/slow/function/closure-default.php.expect [new file with mode: 0644]
hphp/test/slow/function/exception-default.php [new file with mode: 0644]
hphp/test/slow/function/exception-default.php.expect [new file with mode: 0644]
hphp/test/slow/function/instance-default.php [new file with mode: 0644]
hphp/test/slow/function/instance-default.php.expect [new file with mode: 0644]
hphp/test/slow/function/non-static-default.php [new file with mode: 0644]
hphp/test/slow/function/non-static-default.php.expect [new file with mode: 0644]
hphp/test/slow/function/short-lambda.php [new file with mode: 0644]
hphp/test/slow/function/short-lambda.php.expect [new file with mode: 0644]
hphp/test/slow/function/ternary-default.php [new file with mode: 0644]
hphp/test/slow/function/ternary-default.php.expect [new file with mode: 0644]
hphp/test/slow/function/undefined-function-default.php [new file with mode: 0644]
hphp/test/slow/function/undefined-function-default.php.expectf [new file with mode: 0644]
hphp/test/zend/bad/Zend/tests/class_name_as_scalar_error_003.php [moved from hphp/test/zend/good/Zend/tests/class_name_as_scalar_error_003.php with 100% similarity]
hphp/test/zend/bad/Zend/tests/class_name_as_scalar_error_003.php.expectf [moved from hphp/test/zend/good/Zend/tests/class_name_as_scalar_error_003.php.expectf with 100% similarity]
hphp/test/zend/bad/Zend/tests/class_name_as_scalar_error_004.php [moved from hphp/test/zend/good/Zend/tests/class_name_as_scalar_error_004.php with 100% similarity]
hphp/test/zend/bad/Zend/tests/class_name_as_scalar_error_004.php.expectf [moved from hphp/test/zend/good/Zend/tests/class_name_as_scalar_error_004.php.expectf with 100% similarity]