Skip to content

Tabs silently break indentation stripping #7834

Open
@roberth

Description

Describe the bug

Tabs are not supported in the indentation stripping parser. This is the right behavior in principle, but when a user does insert a tab, the behavior does not match their indentation. The right solution is to warn and let the user fix the problem. Supporting tabs is wrong, because tab width is undefined and will never be defined consistently.

Adding a warning may make '' '' strings annoying for users who have to write strings with tabs at the start of lines, but their solution is already fragile, so they should move to explicit tabs ("\t") or put the string in a separate file.

Steps To Reproduce

  1. Write a file with a '' string indented with tabs or a mix of spaces and tabs.
  2. Parsed string contains tab characters.

Expected behavior

Warn when the first tab is encountered in the indentation stripping logic. Suggest alternatives, for both cases: user wants tabs stripped, or (less likely, current behavior) user wants to keep tabs in their string.

nix-env --version output

Additional context

Removing tabs from indented strings is a hash-changing breaking change. (edit: 2024-10)

Priorities

Add 👍 to issues you find important.

Metadata

Assignees

No one assigned

    Labels

    breakingChanges we can't make without breaking old expressions, changing hashes, etcbuglanguageThe Nix expression language; parser, interpreter, primops, evaluation, etc

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions