nixfmt icon indicating copy to clipboard operation
nixfmt copied to clipboard

Error when carriage return used as linebreak in comment

Open 9999years opened this issue 11 months ago • 2 comments

Description

nixfmt errors when a carriage return is used as a linebreak in a comment.

Small example input

{
  x = #^M1;
}

(Where ^M is a literal carriage return character.)

We can see that nix-instantiate parses the file OK:

$ xxd crlf.nix
00000000: 7b0a 2020 7820 3d20 230d 313b 0a7d 0a    {.  x = #.1;.}.
$ nix-instantiate --parse crlf.nix
{ x = 1; }

Actual output

crlf.nix:2:8:
  |
1;|   x = #
  |        ^^^^
unexpected "<carriage return>1;<newline>}<newline>"
expecting expression

9999years avatar Mar 27 '24 20:03 9999years