Skip to content

Commit 37266ee

Browse files
committed
[ fix ] Support matching on Type in impossible cases
1 parent feb1bc9 commit 37266ee

File tree

5 files changed

+16
-12
lines changed

5 files changed

+16
-12
lines changed

src/TTImp/Impossible.idr

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,9 @@ mutual
193193
go (IMustUnify fc r tm) exps autos named
194194
= Erased fc . Dotted <$> go tm exps autos named
195195
go (IPrimVal fc c) _ _ _ = pure (PrimVal fc c)
196-
-- We're taking UniqueDefault here, _and_ we're falling through to nextVar otherwise, which is sketchy.
197-
-- On option is to try each and emit an AmbiguousElab? We maybe should respect `UniqueDefault` if there
196+
go (IType fc) _ _ _ = pure (TType fc $ MN "top" 0)
197+
-- We're taking UniqueDefault here, _and_ we're falling through to error otherwise, which is sketchy.
198+
-- One option is to try each and emit an AmbiguousElab? We maybe should respect `UniqueDefault` if there
198199
-- is no evidence (mty), but we should _try_ to resolve here if there is an mty.
199200
go (IAlternative _ (UniqueDefault tm) _) exps autos named
200201
= go tm exps autos named

tests/idris2/coverage/coverage029/expected

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,4 @@
11
1/1: Building Main (Main.idr)
2-
Warning: Main:4:11--4:15:Unsupported term in impossible clause: Type
3-
4-
Main:4:11--4:15
5-
1 | import Language.Reflection
6-
2 |
7-
3 | matchType : Bool -> Void
8-
4 | matchType Type impossible
9-
^^^^
10-
112
Warning: Main:7:12--7:20:Unsupported term in impossible clause: `((fromInteger 1 + fromInteger 1))
123

134
Main:7:12--7:20
@@ -165,7 +156,7 @@ Main:3:1--3:25
165156
^^^^^^^^^^^^^^^^^^^^^^^^
166157

167158
Missing cases:
168-
matchType _
159+
matchType True
169160

170161
Error: matchWith is not covering.
171162

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
%default total
2+
3+
data X : Type -> Type where
4+
MkX : (a : Type) -> X a
5+
6+
f : X Nat -> ()
7+
f (MkX Type) impossible
8+
f (MkX Nat) = ()
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1/1: Building Main (Main.idr)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
. ../../../testutils.sh
2+
3+
check Main.idr

0 commit comments

Comments
 (0)