question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Spurious pattern exhaustivity warning when one type parameter lower-bounds another

See original GitHub issue

This example:

sealed trait Parent
final case class Leaf[A, B >: A](a: A, b: B) extends Parent

def run(x: Parent): Unit = x match {
  case Leaf(a, b) =>
}

Leads to the following spurious warning:

-- [E029] Pattern Match Exhaustivity Warning:
6 |def run(x: Parent): Unit = x match {
  |                           ^
  |                           match may not be exhaustive.
  |
  |                           It would fail on pattern case: Leaf(_, _)
  |
  | longer explanation available when compiling with `-explain`
1 warning found

I suspect the issue to be different from #15522, since it is present on both main and 3.1.2.

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
smartercommented, Jul 12, 2022

note the asymmetry. To support F-bounds we only allow recursion in upper bounds.

Related: I realized recently that despite our best effort we could still get recursion in lower bounds: https://github.com/lampepfl/dotty/issues/15280 and I have no idea how to deal with that properly

0reactions
SethTisuecommented, Jul 14, 2022

Note that the original test case is fixable just with the frozen_<:< change.

So perhaps there’s yet another possible solution path here, namely:

Prevent the type avoidance crash (which only arises when we change the rhs of the pattern from () to a) by making type avoidance (or whatever relevant piece of machinery that type avoidance is employing) not choke on the cycle.

Read more comments on GitHub >

github_iconTop Results From Across the Web

3.1.3 regression: spurious unreachable warning · Issue #15522 ...
Spurious pattern exhaustivity warning when one type parameter lower-bounds another #15523. Open. @dwijnand dwijnand self-assigned this on Jun 27.
Read more >
scala - Type parameter circumvents match exhaustivity warning
If the selector of a pattern match is an instance of a sealed class, the compilation of pattern matching can emit warnings which...
Read more >
Spurious Ambiguity and Focalization | Computational Linguistics
Spurious ambiguity is the phenomenon whereby distinct derivations in grammar may assign the same structural reading, resulting in redundancy in the parse ...
Read more >
Declarations - Kotlin language specification
In all cases, it is forbidden if two or more secondary constructors form a delegation loop. Class constructors (both primary and secondary) may...
Read more >
NUREG/CR-6823 - Handbook of Parameter Estimation for ...
Parameter Estimation Using Data from Different Sources .1-3 ... MLEs and 90% confidence intervals for p, for three types of demand and for...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found