Synthetica9 / nix-linter

Linter for the Nix expression language
BSD 3-Clause "New" or "Revised" License
158 stars 16 forks source link

LetBraces, redundant, rare, presumably old syntax #47

Closed roberth closed 3 years ago

roberth commented 3 years ago

I found this in the Nix test suite:

let {
  x = 1;
  body = x;
}

I've never noticed it before and I've been editing a lot of Nix code. This construct is redundant and body is a completely arbitrary non-keyword. No-one should use it.

Here's a parser production for it. It's desugared immediately to (rec { }).body. I've also pasted REC for reference.

  | LET '{' binds '}'
    { $3->recursive = true; $$ = new ExprSelect(noPos, $3, data->symbols.create("body")); }
  | REC '{' binds '}'
    { $3->recursive = true; $$ = $3; }
Synthetica9 commented 3 years ago

This would have to be fixed in hnix, not here. Closing for now.