oppiliappan / statix

lints and suggestions for the nix programming language
https://git.peppe.rs/languages/statix/about
MIT License
552 stars 21 forks source link

Syntax error on correct file #75

Open josqu4red opened 1 year ago

josqu4red commented 1 year ago

When running statix on this file - which is otherwise valid and working - I get this output:

[bin/src/config.rs:79] [self.ignore.as_slice(), extra_ignores].concat() = []
[E00] Error: Syntax error
    ╭─[./lib/default.nix:69:52]
    │
 69 │ ╭─▶       ++ ifExists ../users/${username}/${hostname}.nix;
 71 │ ├─▶ }
    · │
    · ╰─────── Unexpected TOKEN_PATH at 1879..1892, wanted any of [TOKEN_IDENT]
────╯
[E00] Error: Syntax error
   ╭─[./lib/default.nix:1:1]
   │
 1 │ { inputs, ... }:
   · │
   · ╰─ Unexpected end of file, wanted any of [TOKEN_IDENT]
───╯
[E00] Error: Syntax error
   ╭─[./lib/default.nix:1:1]
   │
 1 │ { inputs, ... }:
   · │
   · ╰─ Unexpected end of file, wanted any of [TOKEN_SEMICOLON]
───╯
[E00] Error: Syntax error
   ╭─[./lib/default.nix:1:1]
   │
 1 │ { inputs, ... }:
   · │
   · ╰─ Unexpected end of file
───╯
[E00] Error: Syntax error
   ╭─[./lib/default.nix:1:1]
   │
 1 │ { inputs, ... }:
   · │
   · ╰─ Unexpected end of file, wanted any of [TOKEN_SEMICOLON]
───╯
[E00] Error: Syntax error
   ╭─[./lib/default.nix:1:1]
   │
 1 │ { inputs, ... }:
   · │
   · ╰─ Unexpected end of file
───╯

Errors disappear if the arg in ++ ifExists ../users/${username}/${hostname}.nix; is quoted as string, but then the code does not work anymore... Did I miss something ?

otavio commented 1 year ago

I also got a similar case which it fails.

otavio commented 1 year ago

One interesting finding is that statix check fails but statix fix works.

oddlama commented 1 year ago

Very simple file to reproduce:

rec {
  a = "test";
  p = ./test/${a}.nix;
}

It seems to not like the interpolation in the path. @josqu4red You can work around that without converting the whole path to a string by appending to at least one static component: ./. + "/test/${a}.nix"