Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: tab support for indentation stripping #9971

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

thecaralice
Copy link

Motivation

Many users prefer using hard tabs for indentation, but the existing indentation stripping logic only considers spaces as indentation characters and therefore doesn't strip any tab characters.

Context

Closes #7834.

Previously, stripIndentation would look for the longest common space-consisting line prefix; now it finds either the longest common space-consisting or tab-consisting prefix. A tab after a space is not considered as indentation, neither is a space after a tab.

@thecaralice thecaralice requested a review from edolstra as a code owner February 8, 2024 17:33
@github-actions github-actions bot added the with-tests Issues related to testing. PRs with tests have some priority label Feb 8, 2024
@tomberek
Copy link
Contributor

tomberek commented Feb 9, 2024

First consideration is if this changes historical evaluation values.

@edolstra
Copy link
Member

edolstra commented Feb 9, 2024

See #2911, where the conclusion was that we cannot make this incompatible change without some kind of language versioning mechanism.

@thecaralice
Copy link
Author

See #2911, where the conclusion was that we cannot make this incompatible change without some kind of language versioning mechanism.

This change is unlikely to break anything, as it only changes how tab-indented files get parsed. More precisely, for an indented string to be affected, every line of text in it must start with a tab and there must be no additional indentation, for example:

''
<tab>something
<tab>something else
<tab>something again
''

The following, however, is not affected by the change:

''
  <tab>something
  <tab>something else
  <tab>something again
''

@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/2024-02-28-nix-team-meeting-129/40499/1

@pennae pennae mentioned this pull request Feb 29, 2024
Copy link
Contributor

@fricklerhandwerk fricklerhandwerk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I gather from #7834 that the actual issue is subtle behavior happening silently, therefore the change mainly needs an (opt-out) warning or error on mixed indentation to reduce opportunities for problems rather than introducing more of them.

Also this needs a release note and documentation in the manual, as this would be a substantial change.

src/libexpr/parser-state.hh Show resolved Hide resolved
src/libexpr/parser-state.hh Outdated Show resolved Hide resolved
src/libexpr/parser-state.hh Outdated Show resolved Hide resolved
@L-as
Copy link
Member

L-as commented Mar 9, 2024

Is there any good argument for why language versioning should be more than a nix-language-version setting along with an attribute in flakes to set it? Flakes are already experimental and don't need an RFC to be changed, and the nix-language-version setting could be guarded behind an experimental feature too.

@fricklerhandwerk
Copy link
Contributor

fricklerhandwerk commented Mar 9, 2024

@L-as that discussion happened on NixOS/rfcs#137. I suggest opening inline comments if you have questions, or, if what you want to add is more on the meta level, continue on the Discourse thread. Please read the RFC text first though, where we collected a wealth of arguments for and against certain approaches. I'd appreciate additions if you find that something is missing.

To summarise: Evolving the language is Hard(tm) given the notions of backwards compatibility guarantees being discussed, as can be observed in this very thread. But we have no agreed-upon stance, not even a clearly delineated group of people with authority to make such a decision. And even if we had the decisionmakers and decisions, we also have a resource and prioritisation problem to solve in order to implement those decisions.

@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/2024-03-11-nix-team-meeting-132/42960/1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
with-tests Issues related to testing. PRs with tests have some priority
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Tabs silently break indentation stripping
8 participants