Open
Description
Describe the bug
This is folklore, but I couldn't find an issue about it anywhere, and as I'm working on standardizing the language I'm confronted with edge cases like this that I'm uncertain about including in the language standard.
map or
is expected to parse, and it does. However, because of the way the grammar is written, it is parsed with a different precedence from other function applications. This results in such ‘wat’ moments as:
Steps To Reproduce
nix-repl> let inherit (builtins) add; x = 2; in add 1 x
3
nix-repl> let inherit (builtins) add; or = 2; in add 1 or
«primop-app»
nix-repl> let x = 2; in [ 1 x ]
[ 1 2 ]
nix-repl> let or = 2; in [ 1 or ]
[ error: attempt to call something which is not a function but an integer
at «string»:1:18:
1| let or = 2; in [ 1 or ]
| ^
nix-repl> let or = 1; in or
error: syntax error, unexpected OR_KW
at «string»:1:16:
1| let or = 1; in or
| ^
Expected behavior
Renaming x
to or
in the above expressions should not change their behavior, and using or
as a variable outside of a function call should also be possible.
nix-env --version
output
Reproduced on master.
Additional context
Priorities
Add 👍 to issues you find important.