Skip to content

Docs: List tokenization has a precendence of 1.5 #12848

@hsjobeki

Description

@hsjobeki

Problem

The current operators precedence is documented as https://nix.dev/manual/nix/2.24/language/operators

Function application has the second highest precedence.
Only attribute selection is higher.

But i found that this is not actually true.

See below:

nix-repl> a = x: x

nix-repl> [ a 10 ]
[
  «lambda @ «string»:1:2»
  10
]

Which is exepected. Since in this case we want to create individual tokens within the list.

While the following feels weird

nix-repl> [ -10 ]  
error: syntax error, unexpected '-'
       at «string»:1:3:
            1| [ -10 ]
             |  

List tokenization seems to have a precedence of 1.5 👀 which i didn't find documented.

nix-repl> set = { a =1; }

nix-repl> [ set.a ]    
[ 1 ]

Proposal

Document the behavior properly.

Checklist


Add 👍 to issues you find important.

Metadata

Metadata

Assignees

No one assigned
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions