Skip to content

End on empty method returning Unit #12150

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

Closed
nicolasstucki opened this issue Apr 19, 2021 · 1 comment · Fixed by #12305
Closed

End on empty method returning Unit #12150

nicolasstucki opened this issue Apr 19, 2021 · 1 comment · Fixed by #12305

Comments

@nicolasstucki
Copy link
Contributor

Compiler version

3.0.0-RC2

Minimized code

def f: Unit =
  
end f

Output

2 |end f
  |^^^
  |postfix operator `f` needs to be enabled
  |by making the implicit value scala.language.postfixOps visible.
  |----
  |This can be achieved by adding the import clause 'import scala.language.postfixOps'
  |or by setting the compiler option -language:postfixOps.
  |See the Scaladoc for value scala.language.postfixOps for a discussion
  |why the feature needs to be explicitly enabled.

Expectation

Should compile or should have a better error message.

It feels like it should behave the same as

def f: Unit = {

}
@nicolasstucki
Copy link
Contributor Author

I ended up in this situation when I did something like this.

def f: Unit =
-  val x = ...
-  g(x)
+  // val x = ...
+  // g(x)
end f

The code was much longer.

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.

2 participants