Created
July 1, 2015 21:35
-
-
Save chinmaygarde/1c0db4de8d03d12c84c3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Foo { | |
Foo operator << (_) => new Foo(); | |
Foo operator <= (_) => new Foo(); | |
// For the last case below | |
Foo operator == (_) => new Foo(); | |
} | |
main(List<String> arguments) { | |
var foo = new Foo(); | |
// This works | |
foo << 1 << 2 << 3 << 4; | |
// This fails to parse | |
// foo <= 1 <= 2 <= 3 <= 4; | |
// I can add brackets to make the parser happy | |
(((foo <= 1) <= 2) <= 3) <= 4; | |
// But why? | |
// Also, why is this fine? | |
foo <= 2 == 3 < 4; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Line 16 fails to parse because, unlike additiveExpression, which is defined to allow multiple operators:
relational expressions are not: