on master help sign in
Fix type class name propagation issue

We weren't shadowing names correctly when a class was parameterised on a single variable and one of the methods bound the same name. This almost never happens, but leads to very odd error messages when it does. Fixes #2026

commitbe1569e66d4d4b6d8927c870530892952310ae3a authorEdwin Brady <ecb10@st-andrews.ac.uk> dateFri 20 Mar 2015, 19:37 (12 years ago) parent63e3ef9
5 files changed+22−1
idris.cabal+3 src/Idris/Elab/Instance.hs+4−1 test/reg060/expected test/reg060/reg060.idr+12 test/reg060/run+3
idris.cabal+3
@@ -298,6 +298,9 @@ Extra-source-files:
298298 test/reg059/run
299299 test/reg059/*.idr
300300 test/reg059/expected
301+ test/reg060/run
302+ test/reg060/*.idr
303+ test/reg060/expected
301304
302305 test/basic001/run
303306 test/basic001/*.idr
src/Idris/Elab/Instance.hs+4−1
@@ -88,6 +88,7 @@ elabInstance info syn doc argDocs what fc cs n ps t expn ds = do
8888 -- where block
8989 wparams <- mapM (\p -> case p of
9090 PApp _ _ args -> getWParams (map getTm args)
91+ a@(PRef fc f) -> getWParams [a]
9192 _ -> return []) ps
9293 let pnames = map pname (concat (nub wparams))
9394 let superclassInstances = map (substInstance ips pnames) (class_default_superclasses ci)
@@ -242,7 +243,9 @@ elabInstance info syn doc argDocs what fc cs n ps t expn ds = do
242243 decorate ns iname (UN n) = NS (SN (MethodN (UN n))) ns
243244 decorate ns iname (NS (UN n) s) = NS (SN (MethodN (UN n))) ns
244245
245− mkTyDecl (n, op, t, _) = PTy emptyDocstring [] syn fc op n t
246+ mkTyDecl (n, op, t, _)
247+ = PTy emptyDocstring [] syn fc op n
248+ (mkUniqueNames [] t)
246249
247250 conbind :: [(Name, PTerm)] -> PTerm -> PTerm
248251 conbind ((c,ty) : ns) x = PPi constraint c ty (conbind ns x)
test/reg060/expectednew file

No changes to the content.

test/reg060/reg060.idrnew file+12
@@ -0,0 +1,12 @@
1+
2+class MyFunctor (f : Type -> Type) where
3+ mymap : (m : a -> b) -> f a -> f b
4+
5+data Foo x y = Bar y
6+
7+instance MyFunctor (Foo m) where
8+ mymap m x = ?wibble
9+
10+instance [foo] Functor m => MyFunctor m where
11+ mymap m x = map m x
12+
test/reg060/runnew file+3
@@ -0,0 +1,3 @@
1+#!/usr/bin/env bash
2+idris $@ reg060.idr --check
3+rm -f *.ibc