Skip to content

Commit 639e49d

Browse files
committed
Add SmartWithUIP test case
We already reject it!
1 parent 4636c18 commit 639e49d

5 files changed

Lines changed: 61 additions & 6 deletions

File tree

src/full/Agda/TypeChecking/Coverage.hs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1443,8 +1443,10 @@ split' checkEmpty ind allowPartialCover inserttrailing
14431443

14441444
where
14451445
inContextOfT, inContextOfDelta2 :: (MonadAddContext tcm) => tcm a -> tcm a
1446-
inContextOfT = addContext tel . escapeContext impossible (x + 1)
1447-
inContextOfDelta2 = addContext tel . escapeContext impossible x
1446+
inContextOfT = addContext tel .
1447+
refreshLocalRewriteRules . escapeContext impossible (x + 1)
1448+
inContextOfDelta2 = addContext tel .
1449+
refreshLocalRewriteRules . escapeContext impossible x
14481450

14491451
-- Debug printing
14501452
debugInit tel x ps cps = liftTCM $ inTopContext $ do

src/full/Agda/TypeChecking/Monad/Context.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ unsafeEscapeContext n = unsafeModifyContext $ cxDrop n
130130
-- | Delete the last @n@ bindings from the context. Any occurrences of
131131
-- these variables are replaced with the given @err@.
132132
--
133-
-- Does not (currently) delete local rewrite rules
133+
-- Does not (currently) delete local rewrite rules (but perhaps it should)
134134
escapeContext :: MonadAddContext m => Impossible -> Int -> m a -> m a
135135
escapeContext err n = updateContext (strengthenS err n) $ cxDrop n
136136

src/full/Agda/TypeChecking/Rules/Data.hs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -703,9 +703,7 @@ checkNoLocalRewrites :: QName -> TCM ()
703703
checkNoLocalRewrites d = do
704704
def <- getConstInfo d
705705
case theDef def of
706-
Datatype { dataPars = npars
707-
, dataIxs = nixs
708-
, dataSort = s}
706+
Datatype { dataPars = npars }
709707
-> do
710708
let t = defType def
711709
TelV params t' <- telViewUpTo npars t

test/Fail/SmartWithUIP.agda

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{-# OPTIONS --without-K --smart-with #-}
2+
3+
open import Agda.Builtin.Equality
4+
import Agda.Builtin.Equality.Rewrite
5+
6+
-- Example due to Jesper Cockx
7+
8+
data Unit : Set where ⟨⟩ : Unit
9+
10+
variable
11+
A B : Set
12+
x y : A
13+
14+
PathOver : (P : A Set) (eq : x ≡ y) P x P y Set
15+
PathOver P refl p q = p ≡ q
16+
17+
hide : Unit A A
18+
hide ⟨⟩ x = x
19+
20+
unitp : (u : Unit) u ≡ ⟨⟩
21+
unitp ⟨⟩ = refl
22+
23+
unitElim : (P : Unit Set) P ⟨⟩ (u : Unit) P u
24+
unitElim P d ⟨⟩ = d
25+
26+
local-reflect : (u : Unit) (eq : hide u x ≡ x)
27+
PathOver (λ v hide v x ≡ x) (unitp u) eq refl
28+
local-reflect {x = x} u eq
29+
rewrite eq rewrite unitp u = refl
30+
31+
uip : (eq : x ≡ x) eq ≡ refl
32+
uip eq = local-reflect ⟨⟩ eq

test/Fail/SmartWithUIP.err

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
SmartWithUIP.agda:28.1-27: warning: -W[no]RewriteLHSReduces
2+
_ : hide ⟨⟩ x ≡ x is not a legal rewrite rule, since the left-hand
3+
side
4+
hide ⟨⟩ x
5+
reduces to
6+
x
7+
when checking that the pattern refl has type u ≡ ⟨⟩
8+
9+
SmartWithUIP.agda:28.1-29.36: warning: -W[no]SmartWithOccursFail
10+
_ : u ≡ w is not a legal rewrite rule, since the LHS occurs in the
11+
RHS or an earlier 'smart with' rewrite rule
12+
when checking that the clause
13+
SmartWithUIP.-rewrite58 {_} {x = x} u eq _ refl rewrite unitp u
14+
= refl
15+
has type
16+
{x.A : Set} {x : x.A} (u : Unit) (eq : hide u x ≡ x) (w : x.A)
17+
{@rewrite w-eq : hide u x ≡ w} (prf : hide u x ≡ x)
18+
{@rewrite prf-eq : eq ≡ prf} →
19+
PathOver (λ v → hide v x ≡ x) (unitp u) eq refl
20+
21+
SmartWithUIP.agda:28.1-27: error: [InvalidatedLocalRewriteRule]
22+
Local rewrite rule invalidated after a pattern-match
23+
when checking that the pattern refl has type u ≡ ⟨⟩

0 commit comments

Comments
 (0)