Skip to content

Commit 1f85265

Browse files
committed
[ re #1632 ] (->) does not unify with any of TCon/Type/PrimVal
1 parent 911a907 commit 1f85265

File tree

6 files changed

+45
-20
lines changed

6 files changed

+45
-20
lines changed

src/TTImp/ProcessDef.idr

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,23 +75,36 @@ impossibleOK : {auto c : Ref Ctxt Defs} ->
7575
{vars : _} ->
7676
Defs -> NF vars -> NF vars -> Core Bool
7777
impossibleOK defs (NTCon _ xn xt xa xargs) (NTCon _ yn yt ya yargs)
78-
= if xn == yn
79-
then anyM (mismatch defs) (zipWith (curry $ mapHom snd) xargs yargs)
80-
else pure False
78+
= if xn /= yn
79+
then pure True
80+
else anyM (mismatch defs) (zipWith (curry $ mapHom snd) xargs yargs)
8181
-- If it's a data constructor, any mismatch will do
8282
impossibleOK defs (NDCon _ _ xt _ xargs) (NDCon _ _ yt _ yargs)
8383
= if xt /= yt
8484
then pure True
8585
else anyM (mismatch defs) (zipWith (curry $ mapHom snd) xargs yargs)
8686
impossibleOK defs (NPrimVal _ x) (NPrimVal _ y) = pure (x /= y)
87-
impossibleOK defs (NDCon _ _ _ _ _) (NPrimVal _ _) = pure True
87+
88+
-- NPrimVal is apart from NDCon, NTCon, NBind, and NType
8889
impossibleOK defs (NPrimVal _ _) (NDCon _ _ _ _ _) = pure True
89-
impossibleOK defs (NTCon _ _ _ _ _) (NPrimVal _ _) = pure True
90+
impossibleOK defs (NDCon _ _ _ _ _) (NPrimVal _ _) = pure True
91+
impossibleOK defs (NPrimVal _ _) (NBind _ _ _ _) = pure True
92+
impossibleOK defs (NBind _ _ _ _) (NPrimVal _ _) = pure True
9093
impossibleOK defs (NPrimVal _ _) (NTCon _ _ _ _ _) = pure True
91-
impossibleOK defs (NTCon _ _ _ _ _) (NType _) = pure True
92-
impossibleOK defs (NType _) (NTCon _ _ _ _ _) = pure True
94+
impossibleOK defs (NTCon _ _ _ _ _) (NPrimVal _ _) = pure True
9395
impossibleOK defs (NPrimVal _ _) (NType _) = pure True
9496
impossibleOK defs (NType _) (NPrimVal _ _) = pure True
97+
98+
-- NTCon is apart from NBind, and NType
99+
impossibleOK defs (NTCon _ _ _ _ _) (NBind _ _ _ _) = pure True
100+
impossibleOK defs (NBind _ _ _ _) (NTCon _ _ _ _ _) = pure True
101+
impossibleOK defs (NTCon _ _ _ _ _) (NType _) = pure True
102+
impossibleOK defs (NType _) (NTCon _ _ _ _ _) = pure True
103+
104+
-- NBind is apart from NType
105+
impossibleOK defs (NBind _ _ _ _) (NType _) = pure True
106+
impossibleOK defs (NType _) (NBind _ _ _ _) = pure True
107+
95108
impossibleOK defs x y = pure False
96109

97110
export
@@ -133,6 +146,9 @@ recoverable defs (NPrimVal _ _) (NTCon _ _ _ _ _) = pure False
133146
-- Type constructor vs. type
134147
recoverable defs (NTCon _ _ _ _ _) (NType _) = pure False
135148
recoverable defs (NType _) (NTCon _ _ _ _ _) = pure False
149+
-- Type constructor vs. binder
150+
recoverable defs (NTCon _ _ _ _ _) (NBind _ _ _ _) = pure False
151+
recoverable defs (NBind _ _ _ _) (NTCon _ _ _ _ _) = pure False
136152

137153
recoverable defs (NTCon _ _ _ _ _) _ = pure True
138154
recoverable defs _ (NTCon _ _ _ _ _) = pure True
@@ -155,6 +171,9 @@ recoverable defs (NApp _ (NRef _ f) fargs) (NApp _ (NRef _ g) gargs)
155171

156172
-- PRIMITIVES
157173
recoverable defs (NPrimVal _ x) (NPrimVal _ y) = pure (x == y)
174+
-- primitive vs. binder
175+
recoverable defs (NPrimVal _ _) (NBind _ _ _ _) = pure False
176+
recoverable defs (NBind _ _ _ _) (NPrimVal _ _) = pure False
158177

159178
-- OTHERWISE: no
160179
recoverable defs x y = pure False

tests/Main.idr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ idrisTestsCoverage = MkTestPool "Coverage checking" [] Nothing
5151
"coverage005", "coverage006", "coverage007", "coverage008",
5252
"coverage009", "coverage010", "coverage011", "coverage012",
5353
"coverage013", "coverage014", "coverage015", "coverage016",
54-
"coverage017", "coverage018"]
54+
"coverage017", "coverage018", "coverage019"]
5555

5656
idrisTestsCasetree : TestPool
5757
idrisTestsCasetree = MkTestPool "Case tree building" [] Nothing

tests/idris2/coverage001/expected

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,3 @@ Vect2:8:1--8:21
1515
^^^^^^^^^^^^^^^^^^^^
1616

1717
1/1: Building Vect3 (Vect3.idr)
18-
Error: Impossible pattern gives an error:
19-
When unifying Nat and Vect ?n ?b.
20-
Mismatch between: Nat and Vect ?n ?b.
21-
22-
Vect3:9:8--9:9
23-
5 | Nil : Vect Z a
24-
6 | (::) : a -> Vect k a -> Vect (S k) a
25-
7 |
26-
8 | zip : Vect n a -> Vect n b -> Vect n (a, b)
27-
9 | zip [] Z impossible
28-
^
29-
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
%default total
2+
3+
data Command : Type -> Type where
4+
Empty : Command ()
5+
Pure : t -> Command t
6+
7+
test : Command (List a) -> ()
8+
test (Pure x) = ()
9+
10+
test2 : Command (a -> b) -> ()
11+
test2 (Pure x) = ()
12+
13+
test3 : Command Type -> ()
14+
test3 (Pure x) = ()

tests/idris2/coverage019/expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1/1: Building Issue1632 (Issue1632.idr)

tests/idris2/coverage019/run

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
rm -rf build
2+
3+
$1 --no-color --no-banner --console-width 0 --check Issue1632.idr

0 commit comments

Comments
 (0)