You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<?hh
class Test {
private $x = [$x ==> $x + 1]; // Syntax error
}
The typechecker is fine with it, the runtime not. This doesn't work with collections either.
The text was updated successfully, but these errors were encountered:
SiebelsTim
changed the title
Syntax error: Cannot create array of lambda in class context
Syntax error: Cannot create array of lambdas in member variables
Oct 13, 2015
I am going over old issues on this repository, to see which ones apply to the current versions of hhvm.
The new behavior (must be a static literal expression) is valid. Hhvm does not (nor PHP) allow things that can not be known statically to appear as constant initializers. A ==> style lambda is very similar to a function() use () {} at runtime. This requires the creation of a Closure object. The [] is not required to trigger this behavior.
Footnote: The legacy Hack Collections were an exception to this rule.
This code is invalid for the same reason.
PHP: PHP Fatal error: Constant expression contains invalid operations
HHVM: Fatal error: Uncaught Error: Invalid expression in constant initializer
https://3v4l.org/Or9LN
https://3v4l.org/PLRkL
The typechecker is fine with it, the runtime not. This doesn't work with collections either.
The text was updated successfully, but these errors were encountered: