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

Restrict outdent in parens for certain region prefixes #22530

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

som-snytt
Copy link
Contributor

Possible fix requires comma at end of line if the indented region was introduced by a colon (and similar prefix tokens).

Fixes #22527

@som-snytt
Copy link
Contributor Author

That breaks sudoku!

      fold((accu: Int, n: Int) =>
           if (invalid(0, x, y, (n + 48).toChar)) accu else {
             m(y)(x) = (n + 48).toChar;
             val newaccu = search(x + 1, y, f, accu);
             m(y)(x) = '0';
             newaccu}, accu, 1, 10)}

which is hard to read and misleading indentation, but is it illegal.

The intuition here would be that if you indent the body of your function literal, you intend it to look like a block, and not mashed together with trailing args.

Restricting the restriction to COLONeol might be intuitive enough, or may be just ad hoc.

-              // For some region prefixes (COLONeol, EQUALS) only OUTDENT if COMMA at EOL
-              if canStartIndentTokens.contains(r.prefix) && !statCtdTokens.contains(r.prefix) then
+              // For region prefix COLONeol, only OUTDENT if COMMA at EOL
+              if r.prefix == COLONeol then

Maybe that is OK, because the colon is special.

I noticed that we wanted templates defined with =, and we wanted = to be :=, and wound up at :.

@som-snytt som-snytt force-pushed the issue/22527-comma-vs-indent branch from dceeef7 to 4362c32 Compare February 6, 2025 17:42
@som-snytt
Copy link
Contributor Author

That breaks scalaz!

  def applyLens[A, B](k: B => A)(implicit e: Equal[A]): Store[A, B] @> B =
    lens(q => {
      val x = Need(q.pos)
      val y = Need(q put x.value)
      Store(b =>
        Store(w => if(e.equal(x.value, w)) b else y.value, x.value), y.value)
    })

where it looks like Store(b => body) because of the indentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Comma in extends or derives clause treated as parameter separator in indentation blocks
1 participant