Another GADT typechecking error
See original GitHub issueCompiler version
3.0.2-RC1
Minimized code
class Module[*[_, _]] {
sealed trait Box[A]
case class Box2x2[A, B, C, D](value: (A * B) * (C * D)) extends Box[(A * B) * (C * D)]
def unbox2[X, Y](box: Box[X * Y]): (X * Y) =
box match {
case Box2x2(v) => v // we know that v has type ((a * b) * (c * d))
// for some types a, b, c, d,
// and that ((a * b) * (c * d)) = (X * Y),
// so v does have the expected return type (X * Y)
}
}
Output
% ~/scala3-3.0.2-RC1/bin/scalac boxes.scala
-- [E007] Type Mismatch Error: boxes.scala:8:24 --------------------------------
8 | case Box2x2(v) => v // we know that v has type ((a * b) * (c * d))
| ^
| Found: (v : A$1 * B$1 * (C$1 * D$1))
| Required: X * Y
|
| where: * is a type in class Module with bounds <: [_, _] =>> Any
longer explanation available when compiling with `-explain`
1 error found
Expectation
The code should typecheck, as per the explanation in the code comment.
Issue Analytics
- State:
- Created 2 years ago
- Comments:9 (9 by maintainers)
Top Results From Across the Web
Scope error with locally abstract type when GADT constructor ...
I've updated the question with an example showing that there are other constructors with other shapes, so that using two locally abstract types ......
Read more >Complete and Decidable Type Inference for GADTs - Microsoft
The type checking problem for GADTs is decidable (CH03; SP07). However, type inference turns out to be extremely difficult. The.
Read more >Configuration - golangci-lint
If no configuration file has been found, GolangCI-Lint will try to find one in your home directory. To see which config file is...
Read more >Building robust Streamlit apps with type-checking
Embracing type-checking will let you avoid such errors. Like other forms of static analysis, type-checking is usually performed by a tool—a ...
Read more >A Complete Guide to Linting Go Programs - freshman.tech
Go already ventures farther than most other programming languages by bundling gofmt ... errcheck - Detect unchecked errors in Go programs.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
#fixed-in-scala2 😛
Yes, though you actually need to phrase it in a way that’s a bit of more general:
(This
Ev
member of course still works for the original problem in this issue.)