Skip to content

No dedicated error code for unreachable since type A and B are unrelated #24789

@WojciechMazur

Description

@WojciechMazur

Snippet below produces both warning and error at the same location. It should have produced a single error with assigned error code.

Compiler version

3.8.1-RC1-bin-20251221-327be51-NIGHTLY

Minimized code

case class A(a: Int)
case class B(b: Int)
case class C(c: Int)

val a = (A(1): A | B) match {
  case A(_) => "OK"
  case B(_) => "OK" 
  case C(_) => "Not OK" 
}

Output

 scala compile no-error-codes -S 3.nightly --server=false
-- [E030] Match case Unreachable Warning: /Users/wmazur/projects/scala/scala3/no-error-codes/case1.scala:8:7 
8 |  case C(_) => "Not OK" 
  |       ^^^^
  |       Unreachable case
-- Error: /Users/wmazur/projects/scala/scala3/no-error-codes/case1.scala:8:7 ---
8 |  case C(_) => "Not OK" 
  |       ^
  |       this case is unreachable since type A | B and class C are unrelated
1 warning found
1 error found

Expectation

It should have produced a single error with assigned error code.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions