-
Notifications
You must be signed in to change notification settings - Fork 80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LHS of assignment must be variable #19
Comments
The same also applies to other expressions that accept only variables on the LHS, for example PHP interprets |
Ahh, makes sense. Thanks for pointing that out! I was wondering why variables were called out separately from expressions in general. For Looking back at my notes, my interpretation of the spec was that
Should |
You're right about However, the spec is incorrect about the precedence of |
👍 |
I also happened to come across the following example that is related to this while looking at an RFC:
|
This does not fix every single edge case. This only fixes the edge cases for unary operators on the left hand side of binary operators expecting a variable. (That probably isn't even every single binary operator or unary operator)
This does not fix every single edge case. This only fixes the edge cases for unary operators on the left hand side of binary operators expecting a variable. (That probably isn't even every single binary operator or unary operator)
For #19: Fix an edge case parsing `=` and `instanceof`
@TysonAndre The affected operators with this restriction are:
The Also, before anyone goes and thinks about closing this issue, note that the previous PR is just a workaround. It alters the precedence of those operators, but that isn't the cause of the issue. For example, the parser will still parse statements such as |
That sounds right, after a few checks. I agree that this should be kept open. I was basing my changes off of the comment from #19 (comment) . But that earlier comment now seems incorrect, according to https://secure.php.net/manual/en/language.operators.precedence.php (Which puts
I missed/misread the followup comment they made.
Also, I'd agree that it looks like https://github.com/php/php-langspec/blob/master/spec/10-expressions.md#assignment-operators limits the valid expression types for lhs
|
This fixes the most common cases for microsoft#19 (there may be other edge cases I haven't considered yet) This also fixes incorrect precedence for `<=>`. It has the same precedence as `==` - https://secure.php.net/manual/en/language.operators.precedence.php has correct information for the `<=>` operator.
This fixes the most common cases for microsoft#19 (there may be other edge cases I haven't considered yet) This also fixes incorrect precedence for `<=>`. It has the same precedence as `==` - https://secure.php.net/manual/en/language.operators.precedence.php has correct information for the `<=>` operator.
This fixes the most common cases for microsoft#19 (there may be other edge cases I haven't considered yet) This also fixes incorrect precedence for `<=>`. It has the same precedence as `==` - https://secure.php.net/manual/en/language.operators.precedence.php has correct information for the `<=>` operator.
Fixes one edge case in microsoft#19 Also, fix parsing of `@$x instanceof $y`. My earlier PR fixed `!$x instanceof $y` but broke that.
Fixes one edge case in microsoft#19 Also, fix parsing of `@$x instanceof $y`. My earlier PR fixed `!$x instanceof $y` but broke that.
Noticed while looking at example 4:
In PHP an expression like
$a == $b = $c
is parsed as$a == ($b = $c)
, because this is the only valid way to parse the code under the constraint that the LHS of an assignment must be a variable. The parser currently treats this as($a == $b) = $c
instead.The text was updated successfully, but these errors were encountered: