Idris2 icon indicating copy to clipboard operation
Idris2 copied to clipboard

"${HOLE NAME} is already defined" in `with`

Open gergoerdi opened this issue 4 years ago • 1 comments

data Name : Type where
     UN : String -> Name -- user written name
     MN : String -> Int -> Name -- machine generated name

data IsVar : Name -> Nat -> List Name -> Type where
     First : IsVar n Z (n :: ns)
     Later : IsVar n i ns -> IsVar n (S i) (m :: ns)

data Var : List Name -> Type where
     MkVar : {i : Nat} -> (0 p : IsVar n i vars) -> Var vars

insertName : {outer : List Name} -> Var (outer ++ inner) -> Var (outer ++ n :: inner)
insertName {outer = []} (MkVar p) = MkVar (Later p)
insertName {outer = (n::ns)} (MkVar First) = MkVar First
insertName {outer = (n::ns)} (MkVar (Later x)) with (insertName ?zz)
  insertName {  outer = (n::ns)} (MkVar (Later x)) | with_pat = ?q___rhs

Note that the hole name ?zz is unique. Still, trying to load this file, I get the following error message:

While processing right hand side of insertName at WarmupExercise/Ex2.idr:30:1--32:1: Main.zz is already defined

gergoerdi avatar Aug 18 '20 09:08 gergoerdi

In #2546 I solved some similar issues with holes in record parameters. The problem is that elaboration duplicates the holes (I'm not sure where it's being duplicated in this case).

gallais avatar Jul 08 '22 11:07 gallais