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.

Unnecessary exhaustivity warning when combining refinement types w/ params

See original GitHub issue

The following code:

object O {
  sealed trait Trait[+A] { type T }
  case class CaseClass[+A](a: A) extends Trait[A] { type T = Nothing }

  def id[TT, A](v: Trait[A] { type T = TT }): Trait[A] { type T = TT } =
    v match {
      case CaseClass(a) => CaseClass(a)
    }
}

causes the following warning:

-- [E028] Pattern Match Exhaustivity Warning: sample/1:6:4 ---------------------
6 |    v match {
  |    ^
  |    match may not be exhaustive.
  |
  |    It would fail on: CaseClass(_)

@liufengyun - this happens because the refinement type forces usage of typeParamMap in instantiate. This in turn initializes the param in the pattern space to Any, so instead of CaseClass[A] we get CaseClass[Any]. This was found when rebasing #3454 - one test had to be ignored. I should also mention that with the POC typechecker integration I’ve described in #3454, this code is handled correctly.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
abgruszeckicommented, Nov 15, 2017

Ah, I think I was misunderstanding wildcard semantics! After some experimentation, it appears that for instance Dog[_] is precisely what I would denote as Dog[K] forSome K. I understand now why using wildcards is correct here.

However, I’m not sure if I properly explained how or why I want to use TVars: once a TVar was used in a space’s type anywhere, its constraints kept in that space’s Context are not adjusted. TVars are only there so that additional constraints can be added to new Contexts created when decomposing spaces. I wanted to highlight that if we go through with typechecker-integrated #3454, this issue would automagically be solved as well.

0reactions
liufengyuncommented, Nov 20, 2017
Read more comments on GitHub >

github_iconTop Results From Across the Web

GADT exhaustiveness check incompleteness #6437 - GitHub
reports a warning for non-exhaustive pattern-matching; but whatever the value of t is, the second argument cannot be U1 (this branch 4 is...
Read more >
Filters and facet filters - Algolia
There is one rule: we combine them using AND - meaning, we take the set of filters from each parameter and link them...
Read more >
Characterisation of molecular motions in cryo-EM single ...
We describe a new tool, called multi-body refinement, which models flexible complexes as a user-defined number of rigid bodies that move ...
Read more >
Exhaustive Testing - an overview | ScienceDirect Topics
Exhaustive testing requires applying 2 n exhaustive patterns to an n-input ... These new tests are executed to refine the suspicious combination set....
Read more >
Technical_Reference.pdf - TOPAS-Academic
LARGE REFINEMENTS WITH TENS OF 1000S OF PARAMETERS. ... Superfluous parentheses and the '&' Type for macros .
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