File tree Expand file tree Collapse file tree
src/full/Agda/TypeChecking Expand file tree Collapse file tree Original file line number Diff line number Diff 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
Original file line number Diff line number Diff 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)
134134escapeContext :: MonadAddContext m => Impossible -> Int -> m a -> m a
135135escapeContext err n = updateContext (strengthenS err n) $ cxDrop n
136136
Original file line number Diff line number Diff line change @@ -703,9 +703,7 @@ checkNoLocalRewrites :: QName -> TCM ()
703703checkNoLocalRewrites 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
Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff line change 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 ≡ ⟨⟩
You can’t perform that action at this time.
0 commit comments