Skip to content

val and single given pattern combination #12629

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
bishabosha opened this issue May 27, 2021 · 3 comments · Fixed by #12631
Closed

val and single given pattern combination #12629

bishabosha opened this issue May 27, 2021 · 3 comments · Fixed by #12631

Comments

@bishabosha
Copy link
Member

bishabosha commented May 27, 2021

Compiler version

3.0.0

Minimized code

case class A(i: Int)
case class B(b: Boolean)

def test =
  val (given A) = A(23)
  val given B = B(false)

Output

compiles ok

Expectation

val given B is treated as a pattern val def, but this is too close to given B = B(false) so I would expect a syntax error in favour of the alias given,

alternatively, with #11897 fixed, it could be a way to define a (non-lazy) given?

@bishabosha bishabosha changed the title val and given pattern combination val and single given pattern combination May 27, 2021
@bishabosha
Copy link
Member Author

bishabosha commented May 27, 2021

@odersky
Copy link
Contributor

odersky commented May 28, 2021

How do you propose to change the syntax to support the distinction?

@bishabosha
Copy link
Member Author

in the dotty meeting we decided to make this an error

@Kordyjan Kordyjan added this to the 3.0.2 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