on master help sign in
Fix arity calculation.
commit7ec435981cf985d1ddc01a84fb9596fc70895710 authorMatus Tejiscak <ziman@functor.sk> dateThu 13 Feb 2014, 14:12 (13 years ago) parentbb02275
1 file changed+6−4
src/Idris/Erasure.hs+6−4
src/Idris/Erasure.hs+6−4
@@ -74,6 +74,7 @@ performUsageAnalysis = do
7474 usage = M.toList minUse
7575
7676 -- Print some debug info.
77+ logLvl 5 $ "Original deps:\n" ++ unlines (map fmtItem . M.toList $ depMap)
7778 logLvl 3 $ "Reachable names:\n" ++ unlines (map (indent . show) . S.toList $ reachableNames)
7879 logLvl 4 $ "Minimal usage:\n" ++ fmtUseMap usage
7980 logLvl 5 $ "Residual deps:\n" ++ unlines (map fmtItem . M.toList $ residDeps)
@@ -116,12 +117,13 @@ performUsageAnalysis = do
116117 checkAccessibility opt (n, reachable)
117118 | [Optimise col nt forc rec inaccessible] <- lookupCtxt n opt
118119 , eargs@(_:_) <- [fmt n (S.toList rs) | (i,n) <- inaccessible, rs <- maybeToList $ IM.lookup i reachable]
119− = ifail $ show n ++ ": inaccessible arguments reachable:\n " ++ intercalate "\n " eargs
120+ = warn $ show n ++ ": inaccessible arguments reachable:\n " ++ intercalate "\n " eargs
120121
121122 | otherwise = return ()
122123 where
123124 fmt n [] = show n ++ " (no more information available)"
124125 fmt n rs = show n ++ " from " ++ intercalate ", " [show rn ++ " arg# " ++ show ri | (rn,ri) <- rs]
126+ warn = logLvl 0
125127
126128-- Find the minimal consistent usage by forward chaining.
127129minimalUsage :: Deps -> (Deps, (Set Name, UseMap))
@@ -385,9 +387,9 @@ buildDepMap ci ctx mainName = addPostulates $ dfs S.empty M.empty [mainName]
385387 -- If the symbol is unknown, we assume that it uses all its arguments.
386388 getArity :: Name -> Int
387389 getArity n = case lookupDef n ctx of
388− [CaseOp ci ty tys def tot cdefs]
389− -> length tys
390− _ -> 0
390+ [CaseOp ci ty tys def tot cdefs] -> length tys
391+ [TyDecl (DCon tag arity) _] -> arity
392+ _ -> 0
391393
392394 -- convert applications of lambdas to lets
393395 -- Note that this transformation preserves de bruijn numbering