NixOS / nix

Nix, the purely functional package manager
https://nixos.org/
GNU Lesser General Public License v2.1
12.8k stars 1.52k forks source link

prim_match and prim_split should preserve string context #2547

Open mightybyte opened 5 years ago

mightybyte commented 5 years ago

The context declared on this line in prim_match

https://github.com/NixOS/nix/blob/master/src/libexpr/primops.cc#L1859

...and passed to forceString on the next line is never used. Is this the intended behavior? It seems like this means that match could match on a path and the path would be lost from the context. So probably a bug?

EDIT: This is also true of prim_split

https://github.com/NixOS/nix/blob/master/src/libexpr/primops.cc#L1899

stale[bot] commented 3 years ago

I marked this as stale due to inactivity. → More info

unclechu commented 3 years ago

I was recently debugging a problem when some of the dependencies were not propagated in my derivation. And it turned out that it was because I used builtins.split "\n" to patch something line by line and then I concatenated all of the lines back with builtins.concatStringsSep "\n". All the string context is gone after builtins.split call. Each string in the resulting array has empty string context.

A composition builtins.concatStringsSep "\n" and builtins.split "\n" is not really idempotent.