-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Allow indentation inside (...)
#8659
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
Conversation
Change the rules so that indentation is recognized everywhere, and not just at the toplevel and insider parentheses.
dfa68fb
to
ef0e7e0
Compare
(...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested passing for these
def foo(x: Int) =
var x1 = x
List(
if x > 0
true
else
false
,
while x1 > 0 do
x1 -= 1
,
while
x1 > 0
do
x1 -= 1
,
try
???
catch
case err =>
finally
println("foo"),
for
i <- 1 to 10
yield
i * 2
,
for _ <- 1 to 3 do
for _ <- 3 to 6 do
x1 += 1
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Edit: it is surprising that these compile (if your mental model was indentation syntax was about column alignment, and not simply that braces are now optional)
def foo(x: Int) =
var x1 = x
List(
while x1 > 0 do
x1 -= 1
)
def foo(x: Int) =
var x1 = x
while x1 > 0 do
x1 -= 1
package example
class Foo:
def foo(x: Int) =
var x1 = x
while x1 > 0 do
x1 -= 1
@bishabosha Why should these examples not pass? Note that the |
@odersky Those last examples I didn't compare to the previous dotty release as I was so surprised, so yes I agree now that those behave as expected. So I suppose the feature really is optional braces, and the realm of aesthetic code alignment is left to linters |
Change the rules so that indentation is recognized everywhere, and
not just at the toplevel and inside braces.