@@ -61,8 +61,10 @@ elabTransform info fc safe lhs_in@(PApp _ (PRef _ tf) _) rhs_in
6161 let lhs_ty = getInferType lhs'
6262 let newargs = pvars i lhs_tm
6363
64− (clhs_tm, clhs_ty) <- recheckC fc [] lhs_tm
64+ (clhs_tm_in, clhs_ty) <- recheckC fc [] lhs_tm
65+ let clhs_tm = renamepats pnames clhs_tm_in
6566 logLvl 3 ("Transform LHS " ++ show clhs_tm)
67+
6668 let rhs = addImplBound i (map fst newargs) rhs_in
6769 ((rhs', defer), _) <-
6870 tclift $ elaborate ctxt (sMN 0 "transRHS") clhs_ty []
@@ -72,8 +74,10 @@ elabTransform info fc safe lhs_in@(PApp _ (PRef _ tf) _) rhs_in
7274 erun fc $ psolve lhs_tm
7375 tt <- get_term
7476 return (runState (collectDeferred Nothing tt) []))
75− (crhs_tm, crhs_ty) <- recheckC fc [] rhs'
77+ (crhs_tm_in, crhs_ty) <- recheckC fc [] rhs'
78+ let crhs_tm = renamepats pnames crhs_tm_in
7679 logLvl 3 ("Transform RHS " ++ show crhs_tm)
80+
7781 -- Types must always convert
7882 case converts ctxt [] clhs_ty crhs_ty of
7983 OK _ -> return ()
@@ -94,6 +98,14 @@ elabTransform info fc safe lhs_in@(PApp _ (PRef _ tf) _) rhs_in
9498 depat (Bind n (PVar t) sc) = depat (instantiate (P Bound n t) sc)
9599 depat x = x
96100
101+ renamepats (n' : ns) (Bind n (PVar t) sc)
102+ = Bind n' (PVar t) (renamepats ns sc) -- all Vs
103+ renamepats _ sc = sc
104+
105+ -- names for transformation variables. Need to ensure these don't clash
106+ -- with any other names when applying rules, so rename here.
107+ pnames = map (\i -> sMN i ("tvar" ++ show i)) [0..]
108+
97109elabTransform info fc safe lhs_in rhs_in
98110 = ierror (At fc (Msg "Invalid transformation rule (must be function application)"))
99111