Skip to content

Commit

Permalink
Declaration in irrelevant context (e.g. where modules) must be irrele…
Browse files Browse the repository at this point in the history
…vant as well.

Fixes part of issue 610.
  • Loading branch information
andreasabel committed Apr 18, 2012
1 parent b40aa6a commit f300ed7
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/full/Agda/TypeChecking/Rules/Decl.hs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,10 @@ checkDecl d = do

-- | Type check an axiom.
checkAxiom :: Info.DefInfo -> Relevance -> QName -> A.Expr -> TCM ()
checkAxiom i rel x e = do
checkAxiom i rel0 x e = do
-- Andreas, 2012-04-18 if we are in irrelevant context, axioms is irrelevant
-- even if not declared as such (Issue 610).
rel <- max rel0 <$> asks envRelevance
t <- isType_ e
reportSDoc "tc.decl.ax" 10 $ sep
[ text $ "checked type signature"
Expand Down
5 changes: 4 additions & 1 deletion test/Common/Equality.agda
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,7 @@ data _≡_ {a} {A : Set a} (x : A) : A → Set a where
{-# BUILTIN REFL refl #-}

subst : {a p}{A : Set a}(P : A Set p){x y : A} x ≡ y P x P y
subst P refl t = t
subst P refl t = t

cong : {a b}{A : Set a}{B : Set b}(f : A B){x y : A} x ≡ y f x ≡ f y
cong f refl = refl
36 changes: 36 additions & 0 deletions test/fail/Issue610.agda
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
-- Andreas, 2012-04-18, bug reported by pumpkingod
module Issue610 where

import Common.Level
open import Common.Equality

data : Set where
record : Set where

record A : Set₁ where
constructor set
field
.a : Set

.get : A Set
get x = helper x
module R where
helper : .A -> Set
helper x = A.a x

ack : A Set
ack x = R.helper x x

hah : set ⊤ ≡ set ⊥
hah = refl

.moo :
moo with cong ack hah
moo | q = subst (λ x x) q _

baa : .⊥
baa ()

yoink :
yoink = baa moo

4 changes: 4 additions & 0 deletions test/fail/Issue610.err
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Issue610.agda:22,9-17
Identifier R.helper is declared irrelevant, so it cannot be used
here
when checking that the expression R.helper x x has type Set

0 comments on commit f300ed7

Please sign in to comment.