-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Structural types regression in 3.3.2-RC1 #18535
Comments
Note that Is it meaningful to you, in your use case, that it's The smart money says that @som-snytt will want to weigh in on this. |
I'm still sensitive about my pandemic pounds, so I won't be weighing in. But the spec (4.1 of what is now "ye olde spec") says if p isn't a name (and underscore is not one), and the p has no bound variables, which underscore hasn't, then you get
compare
|
I wasn't aware of these subtleties between named and underscore variables. Thanks for the explanations. It does not however change this issue. I changed the code to a named variable, and added a motivating example for the feature |
I admit ignorance: why does this compile in Scala 3? scala> case class Foo(i: Int)
// defined case class Foo
scala> Foo(0)._1
val res0: Int = 0 It doesn't compile in Scala 2:
|
Bisect points to f29013c which now makes the typer distinguish structural types using |
Oh! The whole code works when we do |
@SethTisue https://github.com/scala/scala/blob/2.13.x/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala#L248 from last year that we can't tinker with it anyway because compatibility. |
Compiler version
Last good version: >= 3.3.2-RC1-bin-20230530-28915c4-NIGHTLY
First bad version: <= 3.3.2-RC1-bin-20230724-ce1ce99-NIGHTLY
Minimized code
Output
Fails to compile with
Expectation
Compiles
Comment
The quite brilliant idea to use structural types like that for use in match types is due to /raghar from Reddit. Hope it's not unintended that it used to work as one of my projects depends on this functionality.
Motivating example:
EDIT: Changed named a previously underscore-named variable, added a motivating example
The text was updated successfully, but these errors were encountered: