Skip to content

new lints: path append is not path resolution #15985

@roberth

Description

@roberth

Is your feature request related to a problem?

path + path has jank.

Misunderstanding of path literals:

nix-repl> ./. + ../foo
/home/user/src/nix/home/user/src/foo

Simply objectionable:

nix-repl> ./. + ./foo  
/home/user/src/nix/home/user/src/nix/foo

Dubious pattern, but pretty sure this is in use, so this should be a separate flag:

nix-repl> ./. + /foo  
/home/user/src/nix/foo

Missing slash in string breaks path-level abstraction boundary:

nix-repl> ./. + "../foo"
/home/user/src/nix../foo

Appended "/.." is resolved without following symlink.
This is probably ok most of the time, so consider

  • separate lint flag
  • check if following symlinks would have been different

Should recommend dirOf to make it actionable.

nix-repl> ./. + "/../foo"
/home/user/src/foo

Proposed solution

A set of new lint- options that check for the above.

Alternative solutions

Additional context

Checklist


Add 👍 to issues you find important.

Metadata

Metadata

Assignees

No one assigned

    Labels

    error-messagesConfusing messages and better diagnosticsfeatureFeature request or proposallanguageThe Nix expression language; parser, interpreter, primops, evaluation, etc
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions