Skip to content

Allow nested end marker scopes at same indentation width #7571

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

Merged
merged 1 commit into from
Nov 19, 2019

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Nov 18, 2019

Example in pos/end-nested.scala

def f[T](x: Option[T]) = x match
  case Some(y) =>
  case None =>
end f

Here, we should not give a "misaligned endmarker" error, which means
we have to skip the nested match scope.

Copy link
Contributor

@liufengyun liufengyun left a comment

Choose a reason for hiding this comment

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

A minor comment, otherwise LGTM

The following code

def f[T](x: Option[T]) = x match
  case Some(y) =>
  case None => "hello"
  end match

will result in an unexpected error message:

4  |  end match
   |  ^
   |The start of this line does not match any of the previous indentation widths.
   |Indentation width of current line : 2 spaces
   |This falls between previous widths: 0 spaces and 2 spaces

@liufengyun liufengyun assigned odersky and unassigned liufengyun Nov 19, 2019
1. Simplify the logic
2. Make end marker errors more reliable by recognizing end markers in more places
3. Allow nested end marker scopes at same indentation width

Example in pos/end-nested.scala

```scala
def f[T](x: Option[T]) = x match
  case Some(y) =>
  case None =>
end f
```
Here, we should not give a "misaligned endmarker" error, which means
we have to skip the nested `match` scope.
@odersky odersky merged commit 7c7fffa into scala:master Nov 19, 2019
@odersky odersky deleted the add-end-nested branch November 19, 2019 22:21
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.

2 participants