Skip to content

Commit

Permalink
Error ProjectionIsIrrelevant instead of GenericError
Browse files Browse the repository at this point in the history
  • Loading branch information
andreasabel committed May 10, 2024
1 parent 9541ca6 commit 2aefef8
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 16 deletions.
6 changes: 6 additions & 0 deletions src/full/Agda/TypeChecking/Errors.hs
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ errorString = \case
SplitInProp{} -> "SplitInProp"
DefinitionIsIrrelevant{} -> "DefinitionIsIrrelevant"
DefinitionIsErased{} -> "DefinitionIsErased"
ProjectionIsIrrelevant{} -> "ProjectionIsIrrelevant"
VariableIsIrrelevant{} -> "VariableIsIrrelevant"
VariableIsErased{} -> "VariableIsErased"
VariableIsOfUnusableCohesion{} -> "VariableIsOfUnusableCohesion"
Expand Down Expand Up @@ -674,6 +675,11 @@ instance PrettyTCM TypeError where
DefinitionIsErased x -> fsep $
"Identifier" : prettyTCM x : pwords "is declared erased, so it cannot be used here"

ProjectionIsIrrelevant x -> vcat
[ fsep [ "Projection " , prettyTCM x, " is irrelevant." ]
, "Turn on option --irrelevant-projections to use it (unsafe)"
]

VariableIsIrrelevant x -> fsep $
"Variable" : prettyTCM (nameConcrete x) : pwords "is declared irrelevant, so it cannot be used here"

Expand Down
5 changes: 1 addition & 4 deletions src/full/Agda/TypeChecking/Modalities.hs
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,7 @@ checkRelevance' x def = do
]
return $ boolToMaybe (not $ drel `moreRelevant` rel) $ DefinitionIsIrrelevant x
where
needIrrProj = Just . GenericDocError <$> do
sep [ "Projection " , prettyTCM x, " is irrelevant."
, " Turn on option --irrelevant-projections to use it (unsafe)."
]
needIrrProj = return $ Just $ ProjectionIsIrrelevant x

-- | The second argument is the definition of the first.
-- Returns 'Nothing' if ok, otherwise the error message.
Expand Down
1 change: 1 addition & 0 deletions src/full/Agda/TypeChecking/Monad/Base.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4669,6 +4669,7 @@ data TypeError
| SplitInProp DataOrRecordE
| DefinitionIsIrrelevant QName
| DefinitionIsErased QName
| ProjectionIsIrrelevant QName
| VariableIsIrrelevant Name
| VariableIsErased Name
| VariableIsOfUnusableCohesion Name Cohesion
Expand Down
6 changes: 2 additions & 4 deletions test/Fail/Issue7193.err
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
Issue7193.agda:12,11-18
Projection
extract
is irrelevant.
Turn on option --irrelevant-projections to use it (unsafe).
Projection extract is irrelevant.
Turn on option --irrelevant-projections to use it (unsafe)
when checking that the expression extract has type ⊤ → A
6 changes: 2 additions & 4 deletions test/Fail/ScopeIrrelevantRecordField.err
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
ScopeIrrelevantRecordField.agda:11,9-17
Projection
Bla.bla0
is irrelevant.
Turn on option --irrelevant-projections to use it (unsafe).
Projection Bla.bla0 is irrelevant.
Turn on option --irrelevant-projections to use it (unsafe)
when checking that the expression Bla.bla0 has type Bla → Set
6 changes: 2 additions & 4 deletions test/Fail/ShapeIrrelevantField.err
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
ShapeIrrelevantField.agda:8,10-17
Projection
Foo.foo
is irrelevant.
Turn on option --irrelevant-projections to use it (unsafe).
Projection Foo.foo is irrelevant.
Turn on option --irrelevant-projections to use it (unsafe)
when checking that the expression Foo.foo has type Foo A → A

0 comments on commit 2aefef8

Please sign in to comment.