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
Instead it has parse error: 'syntax error, unexpected '~', expecting ',' or ')''. Apparently the issue is with expression() identifier which doesnt seem to work, its a bug with Yay library. I wonder if you have a workaround for this issue, or we may have to wait a response from marcioAlmada to fix Yay. Or if you dont have the same problem as I do, lemme know too.
The text was updated successfully, but these errors were encountered:
By performing the following tests I was able to find out what the issue is:
$filtered = array_filter($amplified, $fruit ~> in_array($fruit, $exclude)); // it works
$filtered = array_filter($amplified, $fruit ~> !in_array($fruit, $exclude)); // it does not work
$result = array_map($x ~> pow($x, 2), range(1, 10)); // it works
$result = array_map($x ~> $x * 2 * ++$y, range(1, 10)); // it does not work
Seems that the yay parser will fail if you apply operators(arithmetic, logic, or whatever) in a simple expression. I dont think this can be resolved without a bug fix from Yay, so at this moment a lesser workaround is to allow wrapping complex expressions with parenthesis(). Here is what I did:
buffer("~>"),
expression() as body,
_() as scope
Changes the middle line like this:
buffer("~>"),
either(expression(), chain(buffer("("), layer() ,buffer(")"))) as body,
_() as scope
With this change, the below expression will work properly:
$filtered = array_filter($amplified, $fruit ~> (!in_array($fruit, $exclude))); // it works now
With all being said, the workaround is not pretty, I hope this issue will be resolved completely following an update from Yay.
It seems that short closure without braces aint working for me. This code cannot be compiled into the correct syntax in PHP:
Instead it has parse error: 'syntax error, unexpected '~', expecting ',' or ')''. Apparently the issue is with expression() identifier which doesnt seem to work, its a bug with Yay library. I wonder if you have a workaround for this issue, or we may have to wait a response from marcioAlmada to fix Yay. Or if you dont have the same problem as I do, lemme know too.
The text was updated successfully, but these errors were encountered: