diff --git a/src/Solcore/Frontend/TypeInference/SccAnalysis.hs b/src/Solcore/Frontend/TypeInference/SccAnalysis.hs index 032b1c5f..1fce37f2 100644 --- a/src/Solcore/Frontend/TypeInference/SccAnalysis.hs +++ b/src/Solcore/Frontend/TypeInference/SccAnalysis.hs @@ -55,14 +55,16 @@ sccContract d = pure d analysis :: (Ord a, Names a, Decl a, Show a, Groupable a) => [a] -> SCC [a] analysis ds = do - let grph = mkGraph ds - cmps = scc grph + grph <- mkGraph ds + let cmps = scc grph case topSort cmps of Left _ -> pure [] Right ds' -> pure $ reverse $ concatMap (groupMutualDefs . toList . N.vertexList1) ds' -mkGraph :: (Ord a, Names a, Decl a) => [a] -> AdjacencyMap a -mkGraph ds = stars $ mkEdges (mkNameEnv ds) ds +mkGraph :: (Ord a, Names a, Decl a, Show a) => [a] -> SCC (AdjacencyMap a) +mkGraph ds = do + let es = mkEdges (mkNameEnv ds) ds + pure (stars es) -- definition of enviroment of definition names @@ -128,9 +130,9 @@ instance Decl (TopDecl Name) where decl (TMutualDef ds) = decl ds decl (TDataDef d) = decl d decl (TSym t) = decl t + decl (TClassDef c) = decl c decl _ = [] - instance Decl (ContractDecl Name) where decl (CDataDecl dt) = decl dt decl (CFieldDecl fd) = decl fd @@ -139,6 +141,12 @@ instance Decl (ContractDecl Name) where = concatMap decl ds decl (CConstrDecl cd) = [] +instance Decl (Class Name) where + decl (Class _ _ n _ _ sigs) + = n : map (qual n) (decl sigs) + where + qual n m = QualName n (pretty m) + -- getting the mentioned names in a declaration class Names a where diff --git a/std/std.solc b/std/std.solc index 81896ebd..25b951b0 100644 --- a/std/std.solc +++ b/std/std.solc @@ -152,7 +152,7 @@ function ge(x:a, y:a) -> bool { forall a. a:Ord => function lt(x:a, y:a) -> bool { - return gt(y,x); + return Ord.gt(y,x); } // --- Arithmetic ---