jtojnar / nixpkgs-hammering

Beat your package expressions into a shape
MIT License
245 stars 14 forks source link

Check string escaping #82

Open sternenseemann opened 3 years ago

sternenseemann commented 3 years ago

Nix has pretty surprising escaping behavior. There are some valid escape sequences (like \\, \n, \r, ...), but if an escape sequence doesn't exist, it just swallows the backslash silently in double quoted strings. This can lead to bugs which are hard to spot especially when using builtins.match which involves a lot of escaping usually.

It should be possible to add a warning to nixpkgs-hammering (maybe using tree-sitter to access the AST).

That problems exist currently is evidenced by https://github.com/NixOS/nixpkgs/pull/114853.

(Also escaping issues in indented strings may exist, but I'm not sure on top of my head.)