Closed akshaal closed 8 months ago
Still crashes as of 3.4.0-RC1-bin-20240112-c50f2ff-NIGHTLY-git-c50f2ff.
This issue was picked for the Issue Spree No. 41 of January 16th, 2024 which takes place in 2 days. @smarter, @jan-pieter, @nmcb will be working on it. If you have any insight into the issue or guidance on how to fix it, please leave it here.
Some observations:
if ... return
blockIt does also work if the case class is replaced by a def:
class Test {
def test(s: String): Unit = {
if (s == null) {
return
}
def g() = ()
}
}
Compilation succeeds when wrapping the case class definition in a block with curly braces
Interesting. The difference there is that the case class and the result gets wrapped in a block:
sbt:scala3> scalac -Xprint:parser tests/pos/i19202.scala
[[syntax trees at end of parser]] // tests/pos/i19202.scala
package <empty> {
class Test {
def test(s: String): Unit =
{
if (s == null)
{
return
}
{
case class XXX() {}
<empty>
}
}
}
}
Without curly braces:
sbt:scala3> scalac -Xprint:parser tests/pos/i19202.scala
[[syntax trees at end of parser]] // tests/pos/i19202.scala
package <empty> {
class Test {
def test(s: String): Unit =
{
if (s == null)
{
return
}
case class XXX() {}
<empty>
}
}
}
...
The exception is a MatchError
thrown from typeSig
when original
is a TypeDef
for which there is node case
:
@noti0na1 will join you to work on this issue.
Turns out the match fails on a TypeDef
. And indeed, when replacing the case class definition with type A = String
we get the same error.
Compiling a minimized example with scala 3.3.1:
results in