Skip to content

Commit

Permalink
Fix Mimer trying bad recursive calls (#7195)
Browse files Browse the repository at this point in the history
* Mimer: use monadic pretty printing combinators

* Mimer: use setMetaOccursCheck instead of creating fresh meta

* add "mimer.trace" debug printing giving a readable trace of the search

* Mimer: remove goalEnv

* add ViewPatterns to default extensions

* Mimer: make sure recursive call components get fresh metas after use

* add a NoSubst newtype wrapper with a trivial Subst instance

* Mimer: take care to only generate terminating recursive calls

* Mimer: issue 7116 test case

* add haddock for NoSubst
  • Loading branch information
UlfNorell committed Mar 20, 2024
1 parent 422b932 commit a43f45c
Show file tree
Hide file tree
Showing 7 changed files with 373 additions and 373 deletions.
1 change: 1 addition & 0 deletions .hlint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@
- -XTypeFamilies
- -XTypeOperators
- -XTypeSynonymInstances
- -XViewPatterns

# Add custom hints for this project
- hint:
Expand Down
1 change: 1 addition & 0 deletions Agda.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ common language
TypeFamilies
TypeOperators
TypeSynonymInstances
ViewPatterns

other-extensions:
CPP
Expand Down
701 changes: 328 additions & 373 deletions src/full/Agda/Mimer/Mimer.hs

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions src/full/Agda/TypeChecking/Substitute/Class.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
module Agda.TypeChecking.Substitute.Class where

import Control.Arrow ((***), second)
import Control.DeepSeq
import GHC.Generics

import Agda.Syntax.Common
import Agda.Syntax.Internal
Expand Down Expand Up @@ -109,6 +111,16 @@ instance Subst QName where
type SubstArg QName = Term
applySubst _ q = q

-- | Wrapper for types that do not contain variables (so applying a substitution is the identity).
-- Useful if you have a structure of types that support substitution mixed with types that don't
-- and need to apply a substitution to the full structure.
newtype NoSubst t a = NoSubst { unNoSubst :: a }
deriving (Generic, NFData, Functor)

instance DeBruijn t => Subst (NoSubst t a) where
type SubstArg (NoSubst t a) = t
applySubst _ x = x

---------------------------------------------------------------------------
-- * Explicit substitutions
---------------------------------------------------------------------------
Expand Down
21 changes: 21 additions & 0 deletions test/interaction/Issue7116.agda
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
module _ (A : Set) where

open import Agda.Builtin.Nat
open import Agda.Builtin.Sigma

data Color : Set where
black : Color

data Tree' : Color Nat Set where
nb : (a : A) {c} {n}
Tree' c n
Tree' black n
Tree' black (suc n)

test : (a : A) {n} (l : Tree' black (suc n)) Σ _ λ c Tree' c (suc n)
test a (nb b l r) = {!!} -- C-c C-a
-- was: internal error
-- should be: black , nb a r r

-- An internal error has occurred. Please report this as a bug.
-- Location of the error: __IMPOSSIBLE__, called at src/full/Agda/TypeChecking/CompiledClause/Match.hs:87:73
2 changes: 2 additions & 0 deletions test/interaction/Issue7116.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
top_command (cmd_load currentFile [])
goal_command 0 cmd_autoOne ""
8 changes: 8 additions & 0 deletions test/interaction/Issue7116.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
(agda2-status-action "")
(agda2-info-action "*Type-checking*" "" nil)
(agda2-highlight-clear)
(agda2-status-action "")
(agda2-info-action "*All Goals*" "?0 : Σ Color (λ c → Tree' c (suc n)) " nil)
((last . 1) . (agda2-goals-action '(0)))
(agda2-give-action 0 "black , nb a r r")
((last . 1) . (agda2-goals-action '()))

0 comments on commit a43f45c

Please sign in to comment.