Misleading error message for "ill-defined escapes" #1169

Open
opened 2026-03-28 00:19:27 +00:00 by mdaniels5757 · 1 comment

Describe the bug

Lix (at git commit 96db7c79cf) correctly detects that the following escape sequence (from github.com/NixOS/nixpkgs@ce7cb362fd/pkgs/by-name/sa/sampo/package.nix (L38)) is bad:

  passthru.updateScript = nix-update-script { extraArgs = [ "--version-regex=sampo-v([0-9\.]*)" ]; };

It issues the following diagnostic:

warning: \. is an ill-defined escape. You can drop the \ and simply write . instead. Use --extra-deprecated-features broken-string-escape to silence this warning.
         at /nix/store/zdgams46mdc2akv368x4132q2zw8n1lk-source/pkgs/by-name/sa/sampo/package.nix:38:91:
             37|
             38|   passthru.updateScript = nix-update-script { extraArgs = [ "--version-regex=sampo-v([0-9\.]*)" ]; };
               |                                                                                           ^
             39|

I take this warning as saying that I should remove the \. But, although that would be equivalent to the existing code, I think that's bad advice, because what was intended in this case (and, I assume, most cases where this warning happens) was "--version-regex=sampo-v([0-9\\.]*)" (i.e. a literal backslash should be present).

Steps To Reproduce

  1. Build nixpkgs' sampo at nixpkgs commit ce7cb362fd3528d6bcb0983072d5399bb5429e72.
  2. Observe warning.

Expected behavior

The warning should both convey that "--version-regex=sampo-v([0-9\.]*)" is equivalent to "--version-regex=sampo-v([0-9.]*)", and that in order to get a literal backslash, it must be escaped.

nix --version output

nix (Lix, like Nix) 2.96.0-dev
System type: x86_64-linux
Additional system types: i686-linux, x86_64-v1-linux, x86_64-v2-linux, x86_64-v3-linux, x86_64-v4-linux
Features: gc, signed-caches
System configuration file: /etc/nix/nix.conf
User configuration files: /home/m/.config/nix/nix.conf:/etc/xdg/nix/nix.conf:/home/m/.nix-profile/etc/xdg/nix/nix.conf:/nix/profile/etc/xdg/nix/nix.conf:/home/m/.local/state/nix/profile/etc/xdg/nix/nix.conf:/etc/profiles/per-user/m/etc/xdg/nix/nix.conf:/nix/var/nix/profiles/default/etc/xdg/nix/nix.conf:/run/current-system/sw/etc/xdg/nix/nix.conf
Store directory: /nix/store
State directory: /nix/var/nix
Data directory: /nix/store/p84k0n7wnak8cndji7fr52irh9gnmsgp-lix-2.96.0-pre-20260317_96db7c79cf2a/share

Additional context

## Describe the bug Lix (at git commit 96db7c79cf2a) correctly detects that the following escape sequence (from https://github.com/NixOS/nixpkgs/blob/ce7cb362fd3528d6bcb0983072d5399bb5429e72/pkgs/by-name/sa/sampo/package.nix#L38) is bad: ```nix passthru.updateScript = nix-update-script { extraArgs = [ "--version-regex=sampo-v([0-9\.]*)" ]; }; ``` It issues the following diagnostic: ``` warning: \. is an ill-defined escape. You can drop the \ and simply write . instead. Use --extra-deprecated-features broken-string-escape to silence this warning. at /nix/store/zdgams46mdc2akv368x4132q2zw8n1lk-source/pkgs/by-name/sa/sampo/package.nix:38:91: 37| 38| passthru.updateScript = nix-update-script { extraArgs = [ "--version-regex=sampo-v([0-9\.]*)" ]; }; | ^ 39| ``` I take this warning as saying that I should remove the `\`. But, although that would be equivalent to the existing code, I think that's bad advice, because what was intended in this case (and, I assume, most cases where this warning happens) was `"--version-regex=sampo-v([0-9\\.]*)"` (i.e. a literal backslash should be present). ## Steps To Reproduce 1. Build nixpkgs' sampo at nixpkgs commit ce7cb362fd3528d6bcb0983072d5399bb5429e72. 2. Observe warning. ## Expected behavior The warning should both convey that `"--version-regex=sampo-v([0-9\.]*)"` is equivalent to `"--version-regex=sampo-v([0-9.]*)"`, and that in order to get a literal backslash, it must be escaped. ## `nix --version` output nix (Lix, like Nix) 2.96.0-dev System type: x86_64-linux Additional system types: i686-linux, x86_64-v1-linux, x86_64-v2-linux, x86_64-v3-linux, x86_64-v4-linux Features: gc, signed-caches System configuration file: /etc/nix/nix.conf User configuration files: /home/m/.config/nix/nix.conf:/etc/xdg/nix/nix.conf:/home/m/.nix-profile/etc/xdg/nix/nix.conf:/nix/profile/etc/xdg/nix/nix.conf:/home/m/.local/state/nix/profile/etc/xdg/nix/nix.conf:/etc/profiles/per-user/m/etc/xdg/nix/nix.conf:/nix/var/nix/profiles/default/etc/xdg/nix/nix.conf:/run/current-system/sw/etc/xdg/nix/nix.conf Store directory: /nix/store State directory: /nix/var/nix Data directory: /nix/store/p84k0n7wnak8cndji7fr52irh9gnmsgp-lix-2.96.0-pre-20260317_96db7c79cf2a/share ## Additional context
Owner

@piegames can you chime in here?

@piegames can you chime in here?
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
lix-project/lix#1169
No description provided.