on master help sign in
Fix parameter name propagation

If a name n appears in a parameter (which is therefore fixed) then n is still fixed itself.

commit9c0581eba0494bdac4b67789cc2da095f9803d04 authorEdwin Brady <ecb10@st-andrews.ac.uk> dateSat 22 Feb 2014, 12:15 (13 years ago) parentecfb293
5 files changed+33−16
idris.cabal+3 src/Idris/ElabDecls.hs+15−16 test/reg036/expected test/reg036/reg036.idr+12 test/reg036/run+3
idris.cabal+3
@@ -218,6 +218,9 @@ Extra-source-files:
218218 test/reg035/*.idr
219219 test/reg035/*.lidr
220220 test/reg035/expected
221+ test/reg036/run
222+ test/reg036/*.idr
223+ test/reg036/expected
221224
222225 test/basic001/run
223226 test/basic001/*.idr
src/Idris/ElabDecls.hs+15−16
@@ -1282,27 +1282,27 @@ getFixedInType i env is tm@(App f a)
12821282 getFixedInType i env is a
12831283getFixedInType i _ _ _ = []
12841284
1285−getFlexInType i env (Bind n (Pi t) sc)
1286− = nub $ getFlexInType i env t ++
1287− getFlexInType i (n : env) (instantiate (P Bound n t) sc)
1288−getFlexInType i env tm@(App f a)
1285+getFlexInType i env ps (Bind n (Pi t) sc)
1286+ = nub $ (if (not (n `elem` ps)) then getFlexInType i env ps t else []) ++
1287+ getFlexInType i (n : env) ps (instantiate (P Bound n t) sc)
1288+getFlexInType i env ps tm@(App f a)
12891289 | (P _ tn _, args) <- unApply tm
12901290 = case lookupCtxt tn (idris_datatypes i) of
12911291 [t] -> nub $ paramNames args env [x | x <- [0..length args],
12921292 not (x `elem` param_pos t)]
1293− ++ getFlexInType i env f ++
1294− getFlexInType i env a
1295− [] -> nub $ getFlexInType i env f ++
1296− getFlexInType i env a
1297− | otherwise = nub $ getFlexInType i env f ++
1298− getFlexInType i env a
1299−getFlexInType i _ _ = []
1293+ ++ getFlexInType i env ps f ++
1294+ getFlexInType i env ps a
1295+ [] -> nub $ getFlexInType i env ps f ++
1296+ getFlexInType i env ps a
1297+ | otherwise = nub $ getFlexInType i env ps f ++
1298+ getFlexInType i env ps a
1299+getFlexInType i _ _ _ = []
13001300
13011301-- Treat a name as a parameter if it appears in parameter positions in
1302−-- types, and never in a non-parameter position in a type.
1302+-- types, and never in a non-parameter position in a (non-param) argument type.
13031303
13041304getParamsInType i env ps t = let fix = getFixedInType i env ps t
1305− flex = getFlexInType i env t in
1305+ flex = getFlexInType i env fix t in
13061306 [x | x <- fix, not (x `elem` flex)]
13071307
13081308paramNames args env [] = []
@@ -1354,11 +1354,10 @@ elabClause info opts (cnum, PClause fc fname lhs_in withs rhs_in whereblock)
13541354 [t] -> t
13551355 _ -> []
13561356 let params = getParamsInType i [] fn_is fn_ty
1357− let flex = getFlexInType i [] fn_ty
13581357 let lhs = mkLHSapp $ stripUnmatchable i $
13591358 propagateParams params fn_ty (addImplPat i (stripLinear i lhs_in))
1360− logLvl 5 ("LHS: " ++ show fc ++ " " ++ show lhs)
1361− logLvl 4 ("Fixed parameters: " ++ show (flex, params) ++ " from " ++ show lhs_in ++
1359+ logLvl 5 ("LHS: " ++ show fc ++ " " ++ showTmImpls lhs)
1360+ logLvl 4 ("Fixed parameters: " ++ show params ++ " from " ++ show lhs_in ++
13621361 "\n" ++ show (fn_ty, fn_is))
13631362
13641363 (((lhs', dlhs, []), probs, inj), _) <-
test/reg036/expectednew file

No changes to the content.

test/reg036/reg036.idrnew file+12
@@ -0,0 +1,12 @@
1+import Data.HVect
2+
3+using (m : Nat, ts : Vect m Type)
4+
5+ data HV : Vect n Type -> Type where
6+ MkHV : HVect ts -> HV ts
7+
8+ showHV : Shows m ts => HV ts -> String
9+ showHV (MkHV v) = show v
10+
11+ instance Shows m ts => Show (HV ts) where
12+ show = showHV
test/reg036/runnew file+3
@@ -0,0 +1,3 @@
1+#!/usr/bin/env bash
2+idris --check reg036.idr
3+rm -f reg036 *.ibc