Skip to content

Excess { required when using polymorphic function lambdas #12277

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
scf37 opened this issue Apr 29, 2021 · 0 comments · Fixed by #12280
Closed

Excess { required when using polymorphic function lambdas #12277

scf37 opened this issue Apr 29, 2021 · 0 comments · Fixed by #12280
Assignees
Milestone

Comments

@scf37
Copy link

scf37 commented Apr 29, 2021

Compiler version

3.0.0-RC3

Minimized code

  def foo(f: => () => Unit): Unit = ???
  def boo(f: [A] => () => Unit): Unit = ???

  foo { () =>  // okay
    println(1)
    println(2)
  }

  boo { [A] => () => // error
    println(1)
    println(2)
  }

  boo { [A] => () => { // okay
    println(1)
    println(2)
  }}

Output

A pure expression does nothing in statement position; you may be omitting necessary parentheses [194:13]
Found:    Unit
Required: PolyFunction{apply: [A](): Unit} [196:12]

Expectation

Same lightweight syntax for polymorphic functions as for "standard" functions
Also by-name parameter support for polymorphic functions could be useful for even clearer syntax.

@odersky odersky self-assigned this Apr 29, 2021
odersky added a commit to dotty-staging/dotty that referenced this issue Apr 29, 2021
Also refactor grammar so that polymorphic lambdas and regular lambdas have the same
level of precedence.

Fixes scala#12277
michelou pushed a commit to michelou/scala3 that referenced this issue May 1, 2021
Also refactor grammar so that polymorphic lambdas and regular lambdas have the same
level of precedence.

Fixes scala#12277
liufengyun pushed a commit to dotty-staging/dotty that referenced this issue May 3, 2021
Also refactor grammar so that polymorphic lambdas and regular lambdas have the same
level of precedence.

Fixes scala#12277
@Kordyjan Kordyjan added this to the 3.0.1 milestone Aug 2, 2023
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.

3 participants