Skip to content

Commit f0165ec

Browse files
[ fix #3669 ] Fix missing handling of dotted patterns (#3671)
* [ fix #3669 ] Handle dotted in `findUsed` * [ fix ] Fix comparing `Dotted` types in `CaseBuilder` * [ fix ] Handle `IMustUnify` in `mkTerm` * [ admin ] Update CHANGELOG --------- Co-authored-by: CodingCellist <[email protected]>
1 parent ca267f5 commit f0165ec

File tree

13 files changed

+39
-1
lines changed

13 files changed

+39
-1
lines changed

CHANGELOG_NEXT.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ should target this file (`CHANGELOG_NEXT`).
99

1010
### Compiler changes
1111

12+
* Fixed missing handling of dotted patterns See
13+
[#3669](https://github.com/idris-lang/Idris2/issues/3669),
14+
[comment](https://github.com/idris-lang/Idris2/issues/3644#issuecomment-3286320272).
1215
* Removed modules and functions moved to `base`:
1316
- `Libraries.Data.Fin``Data.Fin`
1417
- `Libraries.Data.IOArray``Data.IOArray`
@@ -22,7 +25,6 @@ should target this file (`CHANGELOG_NEXT`).
2225
- `Libraries.Data.SortedMap``Data.SortedMap`
2326
- `Libraries.Data.SortedSet``Data.SortedSet`
2427
- `Libraries.Utils.Binary.bufferData'``Data.Buffer.bufferData'`
25-
2628
* Removed unused functions:
2729
- `Libraries.Data.List.Extra`: `breakAfter`, `splitAfter` and `zipMaybe`
2830
- `Libraries.Data.List.Quantifiers.Extra.tabulate`.

src/Core/Case/CaseBuilder.idr

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -798,6 +798,8 @@ sameType {ns} fc phase fn env (p :: xs)
798798
headEq (NPrimVal _ c) (NPrimVal _ c') _ = c == c'
799799
headEq (NType {}) (NType {}) _ = True
800800
headEq (NApp _ (NRef _ n) _) (NApp _ (NRef _ n') _) RunTime = n == n'
801+
headEq (NErased _ (Dotted x)) y ph = headEq x y ph
802+
headEq x (NErased _ (Dotted y)) ph = headEq x y ph
801803
headEq (NErased {}) _ RunTime = True
802804
headEq _ (NErased {}) RunTime = True
803805
headEq _ _ _ = False

src/Core/Env.idr

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,8 @@ mutual
221221
= findUsed env (findUsed env used ty) tm
222222
findUsed env used (TForce fc r tm)
223223
= findUsed env used tm
224+
findUsed env used (Erased fc (Dotted tm))
225+
= findUsed env used tm
224226
findUsed env used _ = used
225227

226228
findUsedInBinder : {vars : _} ->

src/TTImp/Impossible.idr

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,8 @@ mutual
162162
= mkTerm fn mty exps (arg :: autos) named
163163
mkTerm (INamedApp fc fn nm arg) mty exps autos named
164164
= mkTerm fn mty exps autos ((nm, arg) :: named)
165+
mkTerm (IMustUnify fc r tm) mty exps autos named
166+
= Erased fc . Dotted <$> mkTerm tm mty exps autos named
165167
mkTerm (IPrimVal fc c) _ _ _ _ = pure (PrimVal fc c)
166168
mkTerm (IAlternative _ (UniqueDefault tm) _) mty exps autos named
167169
= mkTerm tm mty exps autos named
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
data Identity : Type -> Type where
2+
MkIdentity : (a : Type) -> a -> Identity a
3+
4+
foo : Identity Bool -> ()
5+
foo (MkIdentity .(Bool) True) = ()
6+
foo (MkIdentity .(Bool) False) = ()
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1/1: Building DottedType (DottedType.idr)

tests/idris2/basic/dotted002/run

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
. ../../../testutils.sh
2+
3+
check DottedType.idr
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
data Identity : Type -> Type where
2+
MkIdentity : (a : Type) -> a -> Identity a
3+
4+
foo : Identity Bool -> Void -> ()
5+
foo (MkIdentity .(Bool) True) _ impossible
6+
foo (MkIdentity .(Bool) False) _ impossible
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1/1: Building DottedTypeImpossible (DottedTypeImpossible.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 DottedTypeImpossible.idr

0 commit comments

Comments
 (0)