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

fewerBraces example does not actually work #18014

Closed
Sporarum opened this issue Jun 20, 2023 · 13 comments · Fixed by #18066
Closed

fewerBraces example does not actually work #18014

Sporarum opened this issue Jun 20, 2023 · 13 comments · Fixed by #18066

Comments

@Sporarum
Copy link
Contributor

Compiler version

Scala 3.3.0

Minimized code & Output

List(1,2,3).map:
  x => // error: indented definitions expected, identifier x found
    val y = x - 1
    y * y

https://scastie.scala-lang.org/2v7yp07mQLicgj9PPuC46g

Taken from optional braces for method arguments

More Minimised

List(1,2,3).map:
  x => // error: indented definitions expected, identifier x found
    x

https://scastie.scala-lang.org/uzRJEI6wTsCrQDAwucv8cg

Expectation

Should not throw an error
(or reference should be updated)

@Sporarum Sporarum added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Jun 20, 2023
@Sporarum
Copy link
Contributor Author

@mbovel Potenitally small enough for a spree ?

@szymon-rd
Copy link
Contributor

Should it actually work? The correct syntax right now is

List(1,2,3).map: x => 
    val y = x - 1
    y * y

@Sporarum
Copy link
Contributor Author

That's why it's still "needs triage", no matter if it's a documentation or an implementation issue, both are on this repo ^^

@Sporarum
Copy link
Contributor Author

In this case, the sip agrees with the reference:
https://docs.scala-lang.org/sips/fewer-braces.html

So I would consider this an implementation bug
(But I don't have a strong opinion on that)

@odersky
Copy link
Contributor

odersky commented Jun 24, 2023

I think it's an implementation bug

@odersky odersky added area:parser and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Jun 24, 2023
@odersky odersky self-assigned this Jun 24, 2023
@odersky
Copy link
Contributor

odersky commented Jun 24, 2023

In fact, this works in 3.3.1 RC1.

@Sporarum
Copy link
Contributor Author

Sporarum commented Jun 26, 2023

Does it ?
Here's what it gives me in scastie with 3.3.1-RC1:

List(1,2,3).map:
  x => // indented definitions expected, identifier x found
    x

https://scastie.scala-lang.org/1ke6Wbu5TYCLR9fwVuIShA

Note that some indent based things behave differently toplevel than they do nested in a block

@Sporarum Sporarum reopened this Jun 26, 2023
@odersky
Copy link
Contributor

odersky commented Jun 26, 2023

It works in the REPL and in a standalone file. Maybe scastie is not on the latest version yet?

@odersky odersky assigned Sporarum and unassigned odersky Jun 26, 2023
@som-snytt
Copy link
Contributor

som-snytt commented Jun 26, 2023

FWIW (Edit: for what it's worth, it compiles for me on HEAD, version shown):

➜  snips ~/projects/dotty/bin/scalac -d /tmp i18014.scala
➜  snips ~/projects/dotty/bin/scalac -version
Scala compiler version 3.3.2-RC1-bin-SNAPSHOT-git-8948092 -- Copyright 2002-2023, LAMP/EPFL

Just trying to keep up.

@Sporarum Sporarum linked a pull request Jun 26, 2023 that will close this issue
@Sporarum
Copy link
Contributor Author

@som-snytt, I don't understand ^^'

@Sporarum
Copy link
Contributor Author

I could not replicate either, so I opened a PR adding relevant tests (which will automatically close this issue)

@szymon-rd
Copy link
Contributor

szymon-rd commented Jun 26, 2023

@Sporarum Scastie has more problems, even with basic examples: https://scastie.scala-lang.org/5B8ER9m9RWyec8LXSzLRow
I reported it to @tgodzik , it should be fixed soon

@Sporarum
Copy link
Contributor Author

I see, thank you !

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

Successfully merging a pull request may close this issue.

4 participants