diff --git a/src/Solcore/Backend/Specialise.hs b/src/Solcore/Backend/Specialise.hs index 5d2144967..434f1a137 100644 --- a/src/Solcore/Backend/Specialise.hs +++ b/src/Solcore/Backend/Specialise.hs @@ -296,7 +296,7 @@ addMethodResolution cname ty fd = do Name s -> QualName cname s let name' = specName qname [ty] let funType = typeOfTcFunDef fd - let fd' = FunDef sig {sigName = name'} (funDefBody fd) + let fd' = FunDef (funIsPublic fd) sig {sigName = name'} (funDefBody fd) addResolution qname funType fd' debug ["+ addMethodResolution: ", show qname, " / ", show name', " : ", pretty funType] @@ -415,10 +415,10 @@ specFunDef fd0 = withLocalState do Nothing -> do let sig' = applytv subst (funSignature fd) -- add a placeholder first to break loops - let placeholder = FunDef sig' [] + let placeholder = FunDef (funIsPublic fd) sig' [] addSpecialisation name' placeholder body' <- specBody (funDefBody fd) - let fd' = FunDef sig' {sigName = name'} body' + let fd' = FunDef (funIsPublic fd) sig' {sigName = name'} body' debug ["+ specFunDef: adding specialisation ", show name', " : ", pretty ty'] addSpecialisation name' fd' return name' @@ -633,7 +633,7 @@ schemeOfTcSignature sig@(Signature vs ps _n args (Just rt) _) = schemeOfTcSignature sig = error ("no return type in signature of: " ++ show (sigName sig)) typeOfTcFunDef :: TcFunDef -> Ty -typeOfTcFunDef (FunDef sig _) = typeOfTcSignature sig +typeOfTcFunDef (FunDef _ sig _) = typeOfTcSignature sig pprRes :: Resolution -> Doc -- type Resolution = (Ty, FunDef Id) @@ -785,7 +785,7 @@ instance HasTV (FunDef Id) where subst <- foldM addRenaming mempty (sigVars sig) let sig' = applytv subst sig let body' = applytv subst (funDefBody fd) - pure (FunDef sig' body', subst) + pure (FunDef (funIsPublic fd) sig' body', subst) addRenaming :: TVSubst -> Tyvar -> SM TVSubst addRenaming b a = do @@ -842,7 +842,7 @@ toMastContractDecl (CMutualDecl ds) = MastCMutualDecl (map toMastContractDecl ds toMastContractDecl d = error $ "toMastContractDecl: unexpected " ++ show d toMastFunDef :: FunDef Id -> MastFunDef -toMastFunDef (FunDef sig body) = +toMastFunDef (FunDef _ sig body) = MastFunDef { mastFunName = sigName sig, mastFunParams = map toMastParam (sigParams sig), diff --git a/src/Solcore/Desugarer/ContractDispatch.hs b/src/Solcore/Desugarer/ContractDispatch.hs index b56df7a41..d02be3e6c 100644 --- a/src/Solcore/Desugarer/ContractDispatch.hs +++ b/src/Solcore/Desugarer/ContractDispatch.hs @@ -63,7 +63,7 @@ findFallback c = listToMaybe [fd | CFunDecl fd <- decls c, isFallback fd] genNameDecls :: Contract Name -> Set (TopDecl Name) genNameDecls (Contract cname _ cdecls) = foldl go Set.empty cdecls where - go acc (CFunDecl (FunDef sig _)) + go acc (CFunDecl (FunDef True sig _)) | sigName sig == fallbackName = acc | otherwise = let dataTy = mkNameTy cname (sigName sig) @@ -79,12 +79,12 @@ genMainFn addMain c@(Contract cname tys cdecls) cdecls'' = if hasConstructor cdecls then cdecls else cdecls ++ [defaultConstructor] cdecls' = Set.unions (map (transformCDecl cname) cdecls'') defaultConstructor = CConstrDecl (Constructor {constrParams = [], constrBody = []}) - mainfn = FunDef (Signature [] [] "main" [] (Just unit) False) body + mainfn = FunDef False (Signature [] [] "main" [] (Just unit) False) body body = [StmtExp (Call Nothing (QualName "RunContract" "exec") [cdata])] cdata = Con "Contract" [methods, fallback] methods = tupleExpFromList (fmap mkMethod (mapMaybe unwrapSigs cdecls)) fallback = case findFallback c of - Just (FunDef sig _) -> + Just (FunDef _ sig _) -> Con "Fallback" [ proxyExp (TyCon (if sigPayable sig then "Payable" else "NonPayable") []), @@ -113,8 +113,8 @@ genMainFn addMain c@(Contract cname tys cdecls) ] mkMethod s = error $ "Internal Error: contract methods must be fully typed: " <> show s - -- skip the optional fallback function in the methods tuple - unwrapSigs (CFunDecl (FunDef s _)) + -- skip the optional fallback function and non-public methods in the methods tuple + unwrapSigs (CFunDecl (FunDef True s _)) | sigName s == fallbackName = Nothing | otherwise = Just s unwrapSigs _ = Nothing @@ -136,7 +136,7 @@ transformConstructor contractName cons where params = constrParams cons argsTuple = (tupleTyFromList (mapMaybe getTy params)) - initFun = CFunDecl (FunDef initSig (constrBody cons)) + initFun = CFunDecl (FunDef False initSig (constrBody cons)) initSig = Signature { sigVars = mempty, @@ -186,7 +186,7 @@ transformConstructor contractName cons memoryT t = TyCon "memory" [t] memoryE e = Con "memory" [e] bytesT = TyCon "bytes" [] - copyArgsFun = CFunDecl (FunDef copySig copyBody) + copyArgsFun = CFunDecl (FunDef False copySig copyBody) startSig = Signature @@ -210,7 +210,7 @@ transformConstructor contractName cons return(0, size) }|] ] - startFun = CFunDecl (FunDef startSig startBody) + startFun = CFunDecl (FunDef False startSig startBody) isTyped (Typed {}) = True isTyped (Untyped {}) = False @@ -236,7 +236,7 @@ mkNameInst (DataTy dname [] []) fname = instName = "SigString", paramsTy = [], mainTy = nameTy, - instFunctions = [FunDef sig body] + instFunctions = [FunDef False sig body] } mkNameInst dt _ = error ("Internal Error: unexpected name type structure: " <> show dt) diff --git a/src/Solcore/Desugarer/DecisionTreeCompiler.hs b/src/Solcore/Desugarer/DecisionTreeCompiler.hs index 7756ad3de..9b2db1322 100644 --- a/src/Solcore/Desugarer/DecisionTreeCompiler.hs +++ b/src/Solcore/Desugarer/DecisionTreeCompiler.hs @@ -82,8 +82,8 @@ instance Compile (Constructor Id) where Constructor ps <$> compile bd instance Compile (FunDef Id) where - compile (FunDef sig bd) = - FunDef sig <$> pushCtx ("function " ++ pretty (sigName sig)) (compile bd) + compile (FunDef p sig bd) = + FunDef p sig <$> pushCtx ("function " ++ pretty (sigName sig)) (compile bd) instance Compile (Stmt Id) where compile (e1 := e2) = diff --git a/src/Solcore/Desugarer/IndirectCall.hs b/src/Solcore/Desugarer/IndirectCall.hs index 1eb956cab..ddfa124db 100644 --- a/src/Solcore/Desugarer/IndirectCall.hs +++ b/src/Solcore/Desugarer/IndirectCall.hs @@ -58,8 +58,8 @@ instance Desugar (Contract Name) where Contract n vs <$> desugar ds instance Desugar (FunDef Name) where - desugar (FunDef sig bdy) = - FunDef sig <$> desugar bdy + desugar (FunDef p sig bdy) = + FunDef p sig <$> desugar bdy instance Desugar (ContractDecl Name) where desugar (CFieldDecl fd) = diff --git a/src/Solcore/Desugarer/UniqueTypeGen.hs b/src/Solcore/Desugarer/UniqueTypeGen.hs index e4cd5dc41..9aab87d0c 100644 --- a/src/Solcore/Desugarer/UniqueTypeGen.hs +++ b/src/Solcore/Desugarer/UniqueTypeGen.hs @@ -33,7 +33,7 @@ instance UniqueTypeGen (TopDecl Name) where uniqueTyGen _ = pure () instance UniqueTypeGen (FunDef Name) where - uniqueTyGen (FunDef sig _) = uniqueTyGen sig + uniqueTyGen (FunDef _ sig _) = uniqueTyGen sig instance UniqueTypeGen (Signature Name) where uniqueTyGen sig = diff --git a/src/Solcore/Frontend/Lexer/SolcoreLexer.hs b/src/Solcore/Frontend/Lexer/SolcoreLexer.hs index 2d972ac7e..7faa87ca4 100644 --- a/src/Solcore/Frontend/Lexer/SolcoreLexer.hs +++ b/src/Solcore/Frontend/Lexer/SolcoreLexer.hs @@ -61,6 +61,7 @@ reservedWords = "function", "fallback", "payable", + "public", "constructor", "return", "lam", diff --git a/src/Solcore/Frontend/Module/Loader.hs b/src/Solcore/Frontend/Module/Loader.hs index 2dc00bfe7..bf93e1537 100644 --- a/src/Solcore/Frontend/Module/Loader.hs +++ b/src/Solcore/Frontend/Module/Loader.hs @@ -496,8 +496,8 @@ stubContractDeclBody decl = decl stubFunDefBody :: FunDef -> FunDef -stubFunDefBody (FunDef sig _body) = - FunDef sig [] +stubFunDefBody (FunDef p sig _body) = + FunDef p sig [] moduleValidationTopDeclSegments :: ModuleGraph -> Mod.ModuleId -> Either String ([Import], [[TopDecl]]) moduleValidationTopDeclSegments graph modulePath = do @@ -1200,7 +1200,7 @@ isImportableTopDecl (TExportDecl _) = False isImportableTopDecl _ = True topDeclNames :: TopDecl -> [Name] -topDeclNames (TFunDef (FunDef sig _)) = [sigName sig] +topDeclNames (TFunDef (FunDef _ sig _)) = [sigName sig] topDeclNames (TSym (TySym n _ _)) = [n] topDeclNames (TClassDef (Class _ _ n _ _ _)) = [n] topDeclNames (TContr (Contract n _ _)) = [n] @@ -1232,8 +1232,9 @@ qualifiedImportStubDecls graph (imp, modulePath) = stubDecls (QualName qualifier (show bindingName)) targetModule qualifyFunctionSignature :: Name -> FunDef -> FunDef -qualifyFunctionSignature qualifier (FunDef sig body) = +qualifyFunctionSignature qualifier (FunDef p sig body) = FunDef + p (sig {sigName = QualName qualifier (show (sigName sig))}) body @@ -1268,8 +1269,9 @@ renameTopDeclTypeRefs renameMap (TSym s) = renameTopDeclTypeRefs _ d = d renameFunDefTypeRefs :: Map Name Name -> FunDef -> FunDef -renameFunDefTypeRefs renameMap (FunDef sig body) = +renameFunDefTypeRefs renameMap (FunDef p sig body) = FunDef + p (renameSignatureTypeRefs renameMap sig) (renameBodyTypeRefs renameMap body) @@ -1572,6 +1574,7 @@ stubType n = stubFunction :: Name -> FunDef stubFunction n = FunDef + False (Signature [] [] n [] Nothing False) [] @@ -1588,7 +1591,7 @@ validationImportedDecls graph (imp, modulePath) = Right [] toValidationImportStub :: TopDecl -> Maybe TopDecl -toValidationImportStub (TFunDef (FunDef sig _)) = +toValidationImportStub (TFunDef (FunDef _ sig _)) = Just (TFunDef (stubFunction (sigName sig))) toValidationImportStub (TSym (TySym n _ _)) = Just (TSym (stubType n)) @@ -1829,7 +1832,7 @@ shadowImportedDecls localDecls = (seen', Just decl') -> (seen', decl' : acc) (seen', Nothing) -> (seen', acc) - filterDecl (termNames, typeNames, classNames, instDecls) d@(TFunDef (FunDef sig _)) + filterDecl (termNames, typeNames, classNames, instDecls) d@(TFunDef (FunDef _ sig _)) | sigName sig `elem` termNames = ((termNames, typeNames, classNames, instDecls), Nothing) | otherwise = ( (sigName sig : termNames, typeNames, classNames, instDecls), @@ -1894,7 +1897,7 @@ instanceDeclHeadKey inst = (instDefault inst, instName inst, paramsTy inst, mainTy inst) topDeclTermNames :: TopDecl -> [Name] -topDeclTermNames (TFunDef (FunDef sig _)) = [sigName sig] +topDeclTermNames (TFunDef (FunDef _ sig _)) = [sigName sig] topDeclTermNames _ = [] topDeclTypeNames :: TopDecl -> [Name] @@ -1922,9 +1925,9 @@ renameTopDeclName oldName newName decl | oldName == newName = decl | otherwise = case decl of - TFunDef (FunDef sig body) + TFunDef (FunDef p sig body) | sigName sig == oldName -> - TFunDef (FunDef (sig {sigName = newName}) body) + TFunDef (FunDef p (sig {sigName = newName}) body) TSym sym@(TySym n _ _) | n == oldName -> TSym (sym {symName = newName}) @@ -1941,7 +1944,7 @@ renameTopDeclName oldName newName decl decl selectTopDeclForExportRef :: ExportedItemRef -> TopDecl -> Maybe TopDecl -selectTopDeclForExportRef itemRef d@(TFunDef (FunDef sig _)) +selectTopDeclForExportRef itemRef d@(TFunDef (FunDef _ sig _)) | exportedItemSourceName itemRef == sigName sig, exportedItemConstructors itemRef == Nothing = Just (renameTopDeclName (exportedItemSourceName itemRef) (exportedItemName itemRef) d) diff --git a/src/Solcore/Frontend/Parser/Decl.hs b/src/Solcore/Frontend/Parser/Decl.hs index 74d1b5196..8d8be62a3 100644 --- a/src/Solcore/Frontend/Parser/Decl.hs +++ b/src/Solcore/Frontend/Parser/Decl.hs @@ -231,9 +231,10 @@ funDefP = try $ withSigPrefix funDefAfterPrefix funDefAfterPrefix :: [Ty] -> [Pred] -> Parser FunDef funDefAfterPrefix vars ctx = do + isPub <- option False (True <$ try (keyword "public")) sig <- signatureP vars ctx body <- braces bodyP - return (FunDef sig (implicitReturn body)) + return (FunDef isPub sig (implicitReturn body)) implicitReturn :: Body -> Body implicitReturn [StmtExp e] = [Return e] @@ -252,7 +253,7 @@ fallbackDefAfterPrefix :: [Ty] -> [Pred] -> Parser FunDef fallbackDefAfterPrefix vars ctx = do sig <- fallbackSignatureP vars ctx body <- braces bodyP - return (FunDef sig (implicitReturn body)) + return (FunDef False sig (implicitReturn body)) fallbackSignatureP :: [Ty] -> [Pred] -> Parser Signature fallbackSignatureP vars ctx = do @@ -314,6 +315,7 @@ contractDeclP = <$> dataP <|> CConstrDecl <$> constructorDeclP + <|> rejectPublicOnImplicitlyPublicP <|> withSigPrefix ( \vars ctx -> CFunDecl @@ -322,6 +324,17 @@ contractDeclP = <|> CFieldDecl <$> fieldDeclP +-- | `fallback` and `constructor` are implicitly public; reject an explicit +-- `public` modifier on them with a clear error rather than a confusing +-- parser failure. +rejectPublicOnImplicitlyPublicP :: Parser a +rejectPublicOnImplicitlyPublicP = do + kw <- try $ do + _ <- keyword "public" + _ <- optional (keyword "payable") + ("fallback" <$ keyword "fallback") <|> ("constructor" <$ keyword "constructor") + fail (kw ++ " is implicitly public; remove the 'public' keyword") + fieldDeclP :: Parser Field fieldDeclP = do n <- Name <$> identifier diff --git a/src/Solcore/Frontend/Pretty/SolcorePretty.hs b/src/Solcore/Frontend/Pretty/SolcorePretty.hs index 6dec25c3e..012f903f8 100644 --- a/src/Solcore/Frontend/Pretty/SolcorePretty.hs +++ b/src/Solcore/Frontend/Pretty/SolcorePretty.hs @@ -268,8 +268,8 @@ instance (Pretty a) => Pretty (Body a) where ppr = vcat . map ppr instance (Pretty a) => Pretty (FunDef a) where - ppr (FunDef sig bd) = - ppr sig + ppr (FunDef isPub sig bd) = + ((if isPub then text "public " else empty) <> ppr sig) <+> lbrace $$ nest 3 (vcat (map ppr bd)) $$ rbrace diff --git a/src/Solcore/Frontend/Pretty/TreePretty.hs b/src/Solcore/Frontend/Pretty/TreePretty.hs index 0b811e985..a2202dcf3 100644 --- a/src/Solcore/Frontend/Pretty/TreePretty.hs +++ b/src/Solcore/Frontend/Pretty/TreePretty.hs @@ -244,8 +244,8 @@ instance Pretty Body where ppr = vcat . map ppr instance Pretty FunDef where - ppr (FunDef sig bd) = - ppr sig + ppr (FunDef isPub sig bd) = + ((if isPub then text "public " else empty) <> ppr sig) <+> lbrace $$ nest 3 (vcat (map ppr bd)) $$ rbrace diff --git a/src/Solcore/Frontend/Syntax/Contract.hs b/src/Solcore/Frontend/Syntax/Contract.hs index 8d608fba4..b657e5486 100644 --- a/src/Solcore/Frontend/Syntax/Contract.hs +++ b/src/Solcore/Frontend/Syntax/Contract.hs @@ -219,7 +219,8 @@ data Field a data FunDef a = FunDef - { funSignature :: Signature a, + { funIsPublic :: Bool, + funSignature :: Signature a, funDefBody :: Body a } deriving (Eq, Ord, Show, Data, Typeable) diff --git a/src/Solcore/Frontend/Syntax/NameResolution.hs b/src/Solcore/Frontend/Syntax/NameResolution.hs index 10ae65bc8..a1cac7f77 100644 --- a/src/Solcore/Frontend/Syntax/NameResolution.hs +++ b/src/Solcore/Frontend/Syntax/NameResolution.hs @@ -116,7 +116,7 @@ topLevelTypeNames = concatMap collect topLevelTermNames :: [S.TopDecl] -> [Name] topLevelTermNames = concatMap collect where - collect (S.TFunDef (S.FunDef sig _)) = [S.sigName sig] + collect (S.TFunDef (S.FunDef _ sig _)) = [S.sigName sig] collect (S.TDataDef (S.DataTy tyCon _ cons)) = map (qualifiedConstructorName tyCon . S.constrName) cons collect _ = [] @@ -124,7 +124,7 @@ topLevelTermNames = concatMap collect contractTermNames :: [S.ContractDecl] -> [Name] contractTermNames = concatMap collect where - collect (S.CFunDecl (S.FunDef sig _)) = [S.sigName sig] + collect (S.CFunDecl (S.FunDef _ sig _)) = [S.sigName sig] collect (S.CDataDecl (S.DataTy tyCon _ cons)) = map (qualifiedConstructorName tyCon . S.constrName) cons collect _ = [] @@ -219,7 +219,7 @@ addContractDecl (S.CDataDecl (S.DataTy n _ cons)) = mapM_ (addDataCon n . S.constrName) cons addContractDecl (S.CFieldDecl (S.Field n _ _)) = addField n -addContractDecl (S.CFunDecl (S.FunDef sig _)) = +addContractDecl (S.CFunDecl (S.FunDef _ sig _)) = addFunctionName (S.sigName sig) addContractDecl _ = pure () @@ -338,7 +338,7 @@ instance Resolve S.PragmaStatus where instance Resolve S.FunDef where type Result S.FunDef = FunDef Name - resolve f@(S.FunDef (S.Signature vs ctx n ps mt pay) bds) = + resolve f@(S.FunDef isPub (S.Signature vs ctx n ps mt pay) bds) = do let ns = map tyconName vs withLocalCtx $ do @@ -351,7 +351,7 @@ instance Resolve S.FunDef where bds' <- resolve bds `wrapError` f let vs' = map TVar ns sig = Signature vs' ctx' n ps' mt' pay - pure (FunDef sig bds') + pure (FunDef isPub sig bds') instance Resolve S.Stmt where type Result S.Stmt = Stmt Name @@ -928,7 +928,7 @@ addTopDecl :: S.TopDecl -> Env -> Env addTopDecl (S.TContr (S.Contract n _ _)) env = addQualifiedModules n $ env {typeEnv = Map.insert n TContract (typeEnv env)} -addTopDecl (S.TFunDef (S.FunDef sig _)) env = +addTopDecl (S.TFunDef (S.FunDef _ sig _)) env = addQualifiedModules (S.sigName sig) $ env {scopeEnv = Map.insert (S.sigName sig) TFunction (scopeEnv env)} addTopDecl (S.TClassDef (S.Class _ _ n _ _ sigs)) env = diff --git a/src/Solcore/Frontend/Syntax/SyntaxTree.hs b/src/Solcore/Frontend/Syntax/SyntaxTree.hs index 8e746aeb2..216175674 100644 --- a/src/Solcore/Frontend/Syntax/SyntaxTree.hs +++ b/src/Solcore/Frontend/Syntax/SyntaxTree.hs @@ -218,7 +218,8 @@ data Field data FunDef = FunDef - { funSignature :: Signature, + { funIsPublic :: Bool, + funSignature :: Signature, funDefBody :: Body } deriving (Eq, Ord, Show, Data, Typeable) diff --git a/src/Solcore/Frontend/TypeInference/Erase.hs b/src/Solcore/Frontend/TypeInference/Erase.hs index ede584f68..d59ec8b26 100644 --- a/src/Solcore/Frontend/TypeInference/Erase.hs +++ b/src/Solcore/Frontend/TypeInference/Erase.hs @@ -31,8 +31,8 @@ instance Erase (Instance Id) where instance Erase (FunDef Id) where type EraseRes (FunDef Id) = FunDef Name - erase (FunDef sig bd) = - FunDef (erase sig) (erase bd) + erase (FunDef p sig bd) = + FunDef p (erase sig) (erase bd) instance Erase (Signature Id) where type EraseRes (Signature Id) = Signature Name diff --git a/src/Solcore/Frontend/TypeInference/InvokeGen.hs b/src/Solcore/Frontend/TypeInference/InvokeGen.hs index 852c788fe..e8661aab3 100644 --- a/src/Solcore/Frontend/TypeInference/InvokeGen.hs +++ b/src/Solcore/Frontend/TypeInference/InvokeGen.hs @@ -67,7 +67,7 @@ createInstance udt fd sch = ssargs = take (length args) (svs ++ sarg) scall = Return (Call Nothing fname ssargs) bdy = Match [discr] [([foldr1 ppair (spvs : sargs)], [scall])] - ifd = FunDef isig [bdy] + ifd = FunDef False isig [bdy] vs' = bv qs `union` bv [tupleArgTy, returnTy, selfTy] `union` bv ifd instd = Instance False vs' qs invokableName [tupleArgTy, returnTy] selfTy [ifd] info [">> Generated invokable instance:\n", pretty instd] diff --git a/src/Solcore/Frontend/TypeInference/SccAnalysis.hs b/src/Solcore/Frontend/TypeInference/SccAnalysis.hs index df794e5c2..37bbb3c9d 100644 --- a/src/Solcore/Frontend/TypeInference/SccAnalysis.hs +++ b/src/Solcore/Frontend/TypeInference/SccAnalysis.hs @@ -124,7 +124,7 @@ instance Decl (Signature Name) where decl s = [sigName s] instance Decl (FunDef Name) where - decl (FunDef sig _) = decl sig + decl (FunDef _ sig _) = decl sig instance Decl (Contract Name) where decl (Contract n _ ds) = n : concatMap decl ds @@ -216,7 +216,7 @@ instance Names (Signature Name) where names ctx `union` names ps `union` names mret instance Names (FunDef Name) where - names (FunDef sig bdy) = + names (FunDef _ sig bdy) = names sig `union` names bdy instance Names (Constructor Name) where diff --git a/src/Solcore/Frontend/TypeInference/TcContract.hs b/src/Solcore/Frontend/TypeInference/TcContract.hs index 0a5e3972c..ea01a303a 100644 --- a/src/Solcore/Frontend/TypeInference/TcContract.hs +++ b/src/Solcore/Frontend/TypeInference/TcContract.hs @@ -243,9 +243,9 @@ extImportedFunDefs fds = do generateTopDeclsFor (zip typedFds (map snd nmschs)) typedImportedFunDef :: FunDef Name -> TcM (FunDef Id) -typedImportedFunDef (FunDef sig _body) = do +typedImportedFunDef (FunDef p sig _body) = do params <- mapM tcParam (sigParams sig) - pure (FunDef sig {sigParams = params} []) + pure (FunDef p sig {sigParams = params} []) checkTopDecl :: TopDecl Name -> TcM () checkTopDecl (TClassDef c) = @@ -256,7 +256,7 @@ checkTopDecl (TDataDef dt) = checkDataType dt checkTopDecl (TSym s) = checkSynonym s -checkTopDecl (TFunDef (FunDef sig _)) = +checkTopDecl (TFunDef (FunDef _ sig _)) = extSignature sig checkTopDecl (TExportDecl _) = pure () checkTopDecl _ = pure () @@ -289,7 +289,7 @@ initializeEnv (Contract _ _ cdecls) = checkDecl :: ContractDecl Name -> TcM () checkDecl (CDataDecl dt) = checkDataType dt -checkDecl (CFunDecl (FunDef sig _)) = +checkDecl (CFunDecl (FunDef _ sig _)) = extSignature sig checkDecl (CFieldDecl fd) = tcField fd >> return () @@ -382,7 +382,7 @@ tcSig (sig, (Forall _ (_ :=> t))) = extractSignatures :: [FunDef Name] -> TcM [(Name, Scheme)] extractSignatures fds = forM fds extractSig where - extractSig (FunDef sig _) + extractSig (FunDef _ sig _) | hasAnn sig = do scheme <- annotatedScheme [] [] sig return (sigName sig, scheme) diff --git a/src/Solcore/Frontend/TypeInference/TcModule.hs b/src/Solcore/Frontend/TypeInference/TcModule.hs index f58d2a9e7..7620e5083 100644 --- a/src/Solcore/Frontend/TypeInference/TcModule.hs +++ b/src/Solcore/Frontend/TypeInference/TcModule.hs @@ -405,13 +405,15 @@ importedModuleLeafName (Name n) = Name n importedModuleLeafName (QualName _ n) = Name n typedForwardingWrapper :: Name -> FunDef Id -> FunDef Id -typedForwardingWrapper qualifier (FunDef sig body) +typedForwardingWrapper qualifier (FunDef isPub sig body) | originalName == Name "revert" = FunDef + isPub (sig {sigName = qualifiedName}) body | otherwise = FunDef + isPub (sig {sigName = qualifiedName}) [Return (Call Nothing targetId args)] where diff --git a/src/Solcore/Frontend/TypeInference/TcStmt.hs b/src/Solcore/Frontend/TypeInference/TcStmt.hs index dc47e0ad6..2ffc2c975 100644 --- a/src/Solcore/Frontend/TypeInference/TcStmt.hs +++ b/src/Solcore/Frontend/TypeInference/TcStmt.hs @@ -511,7 +511,7 @@ createClosureFun fn freeIds cdt args bdy ps ty = sig = Signature vs' ps0 fn args' (Just retTy1) False bdy' <- createClosureBody cName cdt freeIds bdy sch <- generalize (ps0, ty') - pure (everywhere (mkT gen) $ FunDef sig bdy', sch) + pure (everywhere (mkT gen) $ FunDef False sig bdy', sch) closureTyCon :: DataTy -> TcM Ty closureTyCon (DataTy dn vs _) = @@ -538,7 +538,7 @@ createClosureFreeFun fn args bdy ps ty = let (_, retTy1) = splitTy ty vs = bv ty `union` bv ps sig = Signature vs ps fn args (Just retTy1) False - pure (everywhere (mkT gen) $ FunDef sig bdy) + pure (everywhere (mkT gen) $ FunDef False sig bdy) tcArgs :: [Param Name] -> TcM ([Param Id], [(Name, Scheme)], [Ty]) tcArgs params = @@ -584,7 +584,7 @@ tiArgs :: [Param Name] -> TcM ([Param Id], [(Name, Scheme)], [Ty]) tiArgs args = unzip3 <$> mapM tiArg args tiFunDef :: FunDef Name -> TcM (FunDef Id, Scheme) -tiFunDef d@(FunDef sig@(Signature _ _ n args _ _) bd) = +tiFunDef d@(FunDef isPub sig@(Signature _ _ n args _ _) bd) = do info ["# tiFunDef:", pretty sig] -- getting fresh type variables for arguments @@ -610,7 +610,7 @@ tiFunDef d@(FunDef sig@(Signature _ _ n args _ _) bd) = ambiguousTypeError sch sig -- elaborating the type signature sig' <- elabSignature [] sig sch - withCurrentSubst (FunDef sig' bd1, sch) + withCurrentSubst (FunDef isPub sig' bd1, sch) ambiguityCheck :: Scheme -> TcM Bool ambiguityCheck (Forall _ (ps :=> ty)) = @@ -648,7 +648,7 @@ annotatedScheme vs' qs (Signature vs ps _ args rt _) = pure (Forall vs1 ((qs ++ ps) :=> (funtype ts t))) tcFunDef :: Bool -> [Tyvar] -> [Pred] -> FunDef Name -> TcM (FunDef Id, Scheme) -tcFunDef incl vs' qs d@(FunDef sig@(Signature vs ps n _ _ _) _) +tcFunDef incl vs' qs d@(FunDef isPub sig@(Signature vs ps n _ _ _) _) | hasAnn sig = do info ["\n# tcFunDef ", pretty d] let vars = vs `union` vs' @@ -657,7 +657,7 @@ tcFunDef incl vs' qs d@(FunDef sig@(Signature vs ps n _ _ _) _) -- instantiate signatures in function definition sks <- mapM (const freshTyVar) vars let env = zip vars sks - FunDef sig1@(Signature _ ps1 _ args1 rt1 _) bd1 = everywhere (mkT (insts @Ty env)) d + FunDef _ sig1@(Signature _ ps1 _ args1 rt1 _) bd1 = everywhere (mkT (insts @Ty env)) d qs1 = everywhere (mkT (insts @Ty env)) qs -- checking if all constraints have a respective class and are well kinded checkConstraints ps `wrapError` d @@ -699,26 +699,27 @@ tcFunDef incl vs' qs d@(FunDef sig@(Signature vs ps n _ _ _) _) subsCheck sig inf ann `wrapError` d -- elaborating function body let ann' = if changeTy then inf else ann - fdt <- elabFunDef vs' sig1 bd1' inf ann' `wrapError` d + fdt <- elabFunDef isPub vs' sig1 bd1' inf ann' `wrapError` d withCurrentSubst (fdt, ann') | otherwise = tiFunDef d -- elaborating function definition elabFunDef :: + Bool -> -- visibility flag (public) [Tyvar] -> -- additional variables which came from outer scope Signature Name -> -- original function signature Body Id -> -- elaborated function body (with fresh variables) Scheme -> -- function infered type Scheme -> -- function annotated type TcM (FunDef Id) -elabFunDef vs sig bdy (Forall _ (_ :=> tinf)) ann@(Forall _ (_ :=> tann)) = +elabFunDef isPub vs sig bdy (Forall _ (_ :=> tinf)) ann@(Forall _ (_ :=> tann)) = do let tinf' = everywhere (mkT toMeta) tinf tann' = everywhere (mkT toMeta) tann s <- unify tinf' tann' sig2 <- elabSignature vs sig ann - let fd2 = everywhere (mkT (apply @Ty s)) (FunDef sig2 bdy) + let fd2 = everywhere (mkT (apply @Ty s)) (FunDef isPub sig2 bdy) pure (everywhere (mkT gen) fd2) toMeta :: Ty -> Ty @@ -1018,8 +1019,8 @@ schemeFromSignature sig = unwords ["Invalid instance member signature (missing return type):", pretty sig] updateSignature :: [Tyvar] -> Name -> FunDef Id -> FunDef Id -updateSignature vs' c (FunDef (Signature vs ps n args rt pay) bd) = - FunDef (Signature (vs \\ vs') ps (QualName c (pretty n)) args rt pay) bd +updateSignature vs' c (FunDef p (Signature vs ps n args rt pay) bd) = + FunDef p (Signature (vs \\ vs') ps (QualName c (pretty n)) args rt pay) bd checkDeferedConstraints :: [(FunDef Id, [Pred])] -> TcM () checkDeferedConstraints = mapM_ checkDeferedConstraint @@ -1198,7 +1199,7 @@ checkCoverage cn ts t = ) checkMethod :: Pred -> FunDef Name -> TcM () -checkMethod ih@(InCls n _ _) d@(FunDef sig _) = +checkMethod ih@(InCls n _ _) d@(FunDef _ sig _) = do -- checking if the signature is fully annotated fullSignature sig @@ -1228,7 +1229,7 @@ fullSignature sig = (throwError $ unlines ["Class and instance methods must have complete type signatures:", pretty sig]) requireAnnotations :: FunDef Name -> TcM () -requireAnnotations (FunDef sig _) = +requireAnnotations (FunDef _ sig _) = unless (isFullyAnnotated sig) $ tcmError $ unlines diff --git a/src/Solcore/Frontend/TypeInference/TcSubst.hs b/src/Solcore/Frontend/TypeInference/TcSubst.hs index 657b45d91..a63811437 100644 --- a/src/Solcore/Frontend/TypeInference/TcSubst.hs +++ b/src/Solcore/Frontend/TypeInference/TcSubst.hs @@ -146,13 +146,13 @@ instance (HasType a) => HasType (Param a) where bv (Untyped i) = bv i instance (HasType a) => HasType (FunDef a) where - apply s (FunDef sig bd) = - FunDef (apply s sig) (apply s bd) - fv (FunDef sig bd) = + apply s (FunDef p sig bd) = + FunDef p (apply s sig) (apply s bd) + fv (FunDef _ sig bd) = fv sig `union` fv bd - mv (FunDef sig bd) = + mv (FunDef _ sig bd) = mv sig `union` mv bd - bv (FunDef sig bd) = + bv (FunDef _ sig bd) = bv sig `union` bv bd instance (HasType a) => HasType (Instance a) where diff --git a/test/Cases.hs b/test/Cases.hs index 27621a7e6..5a0ed6ad6 100644 --- a/test/Cases.hs +++ b/test/Cases.hs @@ -272,6 +272,8 @@ cases = runTestForFile "EvenOdd.solc" caseFolder, runTestExpectingFailure "fallback-with-args.solc" caseFolder, runTestExpectingFailure "fallback-with-return.solc" caseFolder, + runTestExpectingFailure "public-fallback.solc" caseFolder, + runTestExpectingFailure "public-constructor.solc" caseFolder, runTestExpectingFailure "Filter.solc" caseFolder, runTestForFile "foo-class.solc" caseFolder, runTestForFile "Foo.solc" caseFolder, diff --git a/test/ModuleTypeCheckTests.hs b/test/ModuleTypeCheckTests.hs index 49e9f4051..6578093ad 100644 --- a/test/ModuleTypeCheckTests.hs +++ b/test/ModuleTypeCheckTests.hs @@ -96,7 +96,8 @@ funDecl :: String -> TopDecl Name funDecl funName = TFunDef FunDef - { funSignature = + { funIsPublic = False, + funSignature = wordSignature funName, funDefBody = [Return (Lit (IntLit 0))] } @@ -109,7 +110,8 @@ badImportedFun :: TopDecl Name badImportedFun = TFunDef FunDef - { funSignature = wordSignature "badImported", + { funIsPublic = False, + funSignature = wordSignature "badImported", funDefBody = [Return (Var (Name "missing"))] } @@ -117,7 +119,8 @@ usesImportedFun :: TopDecl Name usesImportedFun = TFunDef FunDef - { funSignature = wordSignature "usesImported", + { funIsPublic = False, + funSignature = wordSignature "usesImported", funDefBody = [Return (Call Nothing (Name "badImported") [])] } diff --git a/test/ParserTests.hs b/test/ParserTests.hs index c05287b38..6d25270dd 100644 --- a/test/ParserTests.hs +++ b/test/ParserTests.hs @@ -349,6 +349,7 @@ declTests = "function answer() -> word { return 42; }" ( TFunDef ( FunDef + False (Signature [] [] "answer" [] (Just word) False) [Return (lit 42)] ) @@ -359,6 +360,7 @@ declTests = "function id(x:word) -> word { return x; }" ( TFunDef ( FunDef + False (Signature [] [] "id" [Typed "x" word] (Just word) False) [Return (var "x")] ) @@ -369,6 +371,7 @@ declTests = "function answer() -> word { 42 }" ( TFunDef ( FunDef + False (Signature [] [] "answer" [] (Just word) False) [Return (lit 42)] ) @@ -379,6 +382,7 @@ declTests = "forall a. function id(x:a) -> a { return x; }" ( TFunDef ( FunDef + False ( Signature [TyCon "a" []] [] @@ -396,6 +400,7 @@ declTests = "forall a. a:Eq => function eqSelf(x:a) -> bool { return x == x; }" ( TFunDef ( FunDef + False ( Signature [TyCon "a" []] [InCls "Eq" (TyCon "a" []) []] @@ -499,6 +504,7 @@ declTests = [] word [ FunDef + False (Signature [] [] "eq" [Typed "x" word, Typed "y" word] (Just bool) False) [Return (ExpEE (var "x") (var "y"))] ] @@ -517,6 +523,7 @@ declTests = [] (TyCon "pair" [TyCon "a" [], TyCon "a" []]) [ FunDef + False ( Signature [] [] @@ -556,6 +563,24 @@ declTests = [] [ CFunDecl ( FunDef + False + (Signature [] [] "get" [] (Just word) False) + [Return (var "x")] + ) + ] + ) + ), + testCase "contract with public function" $ + parsesAs + topDeclP + "contract C { public function get() -> word { return x; } }" + ( TContr + ( Contract + "C" + [] + [ CFunDecl + ( FunDef + True (Signature [] [] "get" [] (Just word) False) [Return (var "x")] ) diff --git a/test/examples/Convertible.solc b/test/examples/Convertible.solc index dad698af6..cccfa06c7 100644 --- a/test/examples/Convertible.solc +++ b/test/examples/Convertible.solc @@ -109,7 +109,7 @@ instance Pair(uint16,Proxy(uint256)):Convertible(uint256) { contract Bar { -function main() -> word { +public function main() -> word { let x = Unit; let y : word = convert(x); return y; diff --git a/test/examples/cases/Add1.solc b/test/examples/cases/Add1.solc index 1c88f1e92..8c47763d2 100644 --- a/test/examples/cases/Add1.solc +++ b/test/examples/cases/Add1.solc @@ -1,5 +1,5 @@ contract Add1 { - function main() -> word { + public function main() -> word { let res: word; assembly { res := add(40, 2) diff --git a/test/examples/cases/Compose.solc b/test/examples/cases/Compose.solc index 25b4cbc20..8b25bc25f 100644 --- a/test/examples/cases/Compose.solc +++ b/test/examples/cases/Compose.solc @@ -1,7 +1,7 @@ contract Compose { - function id(x : word) -> word { return x; } + public function id(x : word) -> word { return x; } - function main() -> word { + public function main() -> word { return id(id(42)); } } diff --git a/test/examples/cases/Compose3.solc b/test/examples/cases/Compose3.solc index e5517b137..d04847e87 100644 --- a/test/examples/cases/Compose3.solc +++ b/test/examples/cases/Compose3.solc @@ -1,11 +1,11 @@ contract Compose { - forall a . function id(x : a) -> a { return x; } + forall a . public function id(x : a) -> a { return x; } - function apply1(f : (word) -> word, a : word) -> word { return f(a); } + public function apply1(f : (word) -> word, a : word) -> word { return f(a); } - function idThenId(x : word) -> word { return id(id(x)); } + public function idThenId(x : word) -> word { return id(id(x)); } - function main() -> word { + public function main() -> word { return apply1(idThenId, 42); } } diff --git a/test/examples/cases/CondExp.solc b/test/examples/cases/CondExp.solc index 1c86ffcd1..4c5a236d7 100644 --- a/test/examples/cases/CondExp.solc +++ b/test/examples/cases/CondExp.solc @@ -1,5 +1,5 @@ contract CondExp { - function main() -> word { + public function main() -> word { return if if true then false else true then if false then 1 else 2 diff --git a/test/examples/cases/EitherModule.solc b/test/examples/cases/EitherModule.solc index 347af8baa..abf8b3939 100644 --- a/test/examples/cases/EitherModule.solc +++ b/test/examples/cases/EitherModule.solc @@ -2,7 +2,7 @@ contract EitherModule { data Either(a,b) = Left(a) | Right(b); data List(a) = Nil | Cons(a,List(a)); - function lefts(xs : List(Either(word,word))) -> List(word) { + public function lefts(xs : List(Either(word,word))) -> List(word) { match xs { | List.Nil => return List.Nil ; | List.Cons(y,ys) => @@ -13,5 +13,5 @@ contract EitherModule { } } - function main() -> word { return 0; } + public function main() -> word { return 0; } } diff --git a/test/examples/cases/Enum.solc b/test/examples/cases/Enum.solc index fe190c8ac..6b977e4ac 100644 --- a/test/examples/cases/Enum.solc +++ b/test/examples/cases/Enum.solc @@ -15,7 +15,7 @@ instance Food : Enum { } contract Food { - function main() -> word { + public function main() -> word { return Enum.fromEnum(Food.Beans); } } diff --git a/test/examples/cases/EvenOdd.solc b/test/examples/cases/EvenOdd.solc index 23249a789..96da4173e 100644 --- a/test/examples/cases/EvenOdd.solc +++ b/test/examples/cases/EvenOdd.solc @@ -2,19 +2,19 @@ contract EvenOdd { data Nat = Zero | Succ(Nat); data Bool = False | True; - function even (n : Nat) -> Bool { + public function even (n : Nat) -> Bool { match n { | Nat.Zero => return Bool.True; | Nat.Succ(m) => return odd(m); } } - function odd(n : Nat) -> Bool { + public function odd(n : Nat) -> Bool { match n { | Nat.Zero => return Bool.False; | Nat.Succ(m) => return even(m); } } - function main() -> word { return 0; } + public function main() -> word { return 0; } } diff --git a/test/examples/cases/GetSet.solc b/test/examples/cases/GetSet.solc index 67bf3ad52..b8da15856 100644 --- a/test/examples/cases/GetSet.solc +++ b/test/examples/cases/GetSet.solc @@ -1,11 +1,11 @@ contract GetSet { value : Word ; - function setValue (x) { + public function setValue (x) { value = x ; } - function getValue () { + public function getValue () { return value ; } } diff --git a/test/examples/cases/GoodInstance.solc b/test/examples/cases/GoodInstance.solc index 08ac278e6..14cf8a799 100644 --- a/test/examples/cases/GoodInstance.solc +++ b/test/examples/cases/GoodInstance.solc @@ -27,5 +27,5 @@ instance Bool : Enum { } contract GoodInstance { - function main() -> Word { return fromEnum(Bool.True);} + public function main() -> Word { return fromEnum(Bool.True);} } diff --git a/test/examples/cases/Id.solc b/test/examples/cases/Id.solc index 18f4e77e6..1594f7cb0 100644 --- a/test/examples/cases/Id.solc +++ b/test/examples/cases/Id.solc @@ -3,7 +3,7 @@ function id (x : word) -> word { } contract Id { - function main () -> word { + public function main () -> word { return id(0); } } diff --git a/test/examples/cases/ListModule.solc b/test/examples/cases/ListModule.solc index 2a8bba0fa..ec5343fa6 100644 --- a/test/examples/cases/ListModule.solc +++ b/test/examples/cases/ListModule.solc @@ -3,7 +3,7 @@ contract ListModule { data Bool = True | False; - forall a b c . function zipWith (f : (a,b) -> c,xs : List(a),ys : List(b)) -> List(c) { + forall a b c . public function zipWith (f : (a,b) -> c,xs : List(a),ys : List(b)) -> List(c) { match xs, ys { | List.Nil, List.Nil => return List.Nil ; | List.Cons(x1,xs1), List.Cons(y1,ys1) => @@ -12,7 +12,7 @@ contract ListModule { } } - forall a b . function foldr(f : (a,b) -> b, v : b, xs : List(a)) -> b { + forall a b . public function foldr(f : (a,b) -> b, v : b, xs : List(a)) -> b { match xs { | List.Nil => return v; | List.Cons(y,ys) => @@ -20,7 +20,7 @@ contract ListModule { } } - function main () -> word { + public function main () -> word { return 0; } } diff --git a/test/examples/cases/Logic.solc b/test/examples/cases/Logic.solc index 6dd840382..e5463613a 100644 --- a/test/examples/cases/Logic.solc +++ b/test/examples/cases/Logic.solc @@ -1,21 +1,21 @@ contract Logic { data Bool = True | False; - function not (x : Bool) -> Bool { + public function not (x : Bool) -> Bool { match x { | Bool.True => return Bool.False ; | Bool.False => return Bool.True ; } } - function and(x : Bool, y : Bool) -> Bool { + public function and(x : Bool, y : Bool) -> Bool { match x, y { | Bool.False, _ => return Bool.False ; | Bool.True , _ => return y ; } } - function and1 (x : Bool, y : Bool) -> Bool { + public function and1 (x : Bool, y : Bool) -> Bool { match x, y { | Bool.False, Bool.False => return Bool.False ; | Bool.True , Bool.False => return Bool.False; @@ -24,12 +24,12 @@ contract Logic { } } - function elim (f : word, g : word, x : Bool) -> word { + public function elim (f : word, g : word, x : Bool) -> word { match x { | Bool.True => return f; | Bool.False => return g; } } - function main() -> word { return 0; } + public function main() -> word { return 0; } } diff --git a/test/examples/cases/MatchCall.solc b/test/examples/cases/MatchCall.solc index 289af174b..c4c4be10c 100644 --- a/test/examples/cases/MatchCall.solc +++ b/test/examples/cases/MatchCall.solc @@ -1,11 +1,11 @@ data Bool = False | True; contract MatchCall { - function f() -> Bool { + public function f() -> Bool { return Bool.True; } - function main() -> word { + public function main() -> word { match f() { | Bool.True => return 42; | Bool.False => return 0; diff --git a/test/examples/cases/Mutuals.solc b/test/examples/cases/Mutuals.solc index 6b1cd6db6..aa2d70e43 100644 --- a/test/examples/cases/Mutuals.solc +++ b/test/examples/cases/Mutuals.solc @@ -1,8 +1,8 @@ contract Mutual { - function main () -> word { + public function main () -> word { return f(); } - function f () -> word { + public function f () -> word { return 42; } } diff --git a/test/examples/cases/NegPair.solc b/test/examples/cases/NegPair.solc index a6663d3fb..d3d9da626 100644 --- a/test/examples/cases/NegPair.solc +++ b/test/examples/cases/NegPair.solc @@ -35,19 +35,19 @@ forall a b . a : Neg, b : Neg => instance (a,b):Neg { contract NegPair { - function bnot(x : B) -> B { + public function bnot(x : B) -> B { match x { | B.T => return B.F; | B.F => return B.T; } } - function fromB(b : B) -> word { + public function fromB(b : B) -> word { match b { | B.F => return 0; | B.T => return 1; } } - function main() -> word { return fromB(fst(Neg.neg((B.F,B.T)))); } + public function main() -> word { return fromB(fst(Neg.neg((B.F,B.T)))); } } diff --git a/test/examples/cases/Option.solc b/test/examples/cases/Option.solc index 29067cb49..5176d111f 100644 --- a/test/examples/cases/Option.solc +++ b/test/examples/cases/Option.solc @@ -1,7 +1,7 @@ contract Option { data Option(a) = None | Some(a); - function join(mmx : Option(Option(word))) -> Option(word) { + public function join(mmx : Option(Option(word))) -> Option(word) { match mmx { | Option.None => return Option.None; | Option.Some(Option.Some(x)) => return Option.Some(x); @@ -9,5 +9,5 @@ contract Option { } } - function main() -> word { return 0; } + public function main() -> word { return 0; } } diff --git a/test/examples/cases/SimpleInvoke.solc b/test/examples/cases/SimpleInvoke.solc index 917d2e6a1..09f5ce97b 100644 --- a/test/examples/cases/SimpleInvoke.solc +++ b/test/examples/cases/SimpleInvoke.solc @@ -11,7 +11,7 @@ instance LambdaTy0(a) : invokable (a, a) { } } contract SimpleLambda { - function f () { + public function f () { let n = LambdaTy0 ; return invokable.invoke(n, 0); } diff --git a/test/examples/cases/SimpleLambda.solc b/test/examples/cases/SimpleLambda.solc index a3df5d694..1a68797e8 100644 --- a/test/examples/cases/SimpleLambda.solc +++ b/test/examples/cases/SimpleLambda.solc @@ -7,7 +7,7 @@ function addWord(x : word, y : word) -> word { } contract SimpleLambda{ - function f (z : word) -> word { + public function f (z : word) -> word { let n = lam (x : word, y : word) { return addWord(x,addWord(y,1)); } ; @@ -16,7 +16,7 @@ contract SimpleLambda{ } ; return m(n(1,0)); } - function main() -> word { + public function main() -> word { return f(40); } } diff --git a/test/examples/cases/add-moritz.solc b/test/examples/cases/add-moritz.solc index 87e55fd81..d3654ec8e 100644 --- a/test/examples/cases/add-moritz.solc +++ b/test/examples/cases/add-moritz.solc @@ -61,7 +61,7 @@ function fun(a : (B, B), b : (B, B)) -> (B, B) { // -> c contract Compose { - function main() -> word { + public function main() -> word { let res = fun ((B.T, B.T, B.F), (B.F, B.F, B.T)); match res { | (r1, r2, r3) => return Typedef.rep(r1); diff --git a/test/examples/cases/app.solc b/test/examples/cases/app.solc index 9d82dd94d..60f4b573d 100644 --- a/test/examples/cases/app.solc +++ b/test/examples/cases/app.solc @@ -15,7 +15,7 @@ function foo() -> word { } contract C { - function main () -> word { + public function main () -> word { return foo(); } } diff --git a/test/examples/cases/array.solc b/test/examples/cases/array.solc index 67b94506f..b587bb4b2 100644 --- a/test/examples/cases/array.solc +++ b/test/examples/cases/array.solc @@ -105,7 +105,7 @@ forall size elem . size : ToWord, elem:MemoryType => instance memory(array(size, contract Array { - function main() -> word { + public function main() -> word { let arr : memory(array(Succ(Succ(Succ(Succ(Zero)))), word)) = memory(42); // = (1,2,3,4,5,6,7,8,9,10); IndexAccessible.set(arr, 3, 33); diff --git a/test/examples/cases/asm-assign-no-return.solc b/test/examples/cases/asm-assign-no-return.solc index 303bd2a3a..2037d58a9 100644 --- a/test/examples/cases/asm-assign-no-return.solc +++ b/test/examples/cases/asm-assign-no-return.solc @@ -1,6 +1,6 @@ // mstore does not return a value, so it cannot be assigned. contract Test { - function main() { + public function main() { let x : word; assembly { x := mstore(1, 1) diff --git a/test/examples/cases/asm-let-no-return.solc b/test/examples/cases/asm-let-no-return.solc index b61a44f70..9a7b997f1 100644 --- a/test/examples/cases/asm-let-no-return.solc +++ b/test/examples/cases/asm-let-no-return.solc @@ -1,6 +1,6 @@ // mstore does not return a value, so it cannot initialize a `let`. contract Test { - function main() { + public function main() { assembly { let x := mstore(1, 1) } diff --git a/test/examples/cases/bool-elim.solc b/test/examples/cases/bool-elim.solc index 5eed843ba..c12366896 100644 --- a/test/examples/cases/bool-elim.solc +++ b/test/examples/cases/bool-elim.solc @@ -8,7 +8,7 @@ data Bool = False | True; } contract Second { - function main() -> word { + public function main() -> word { second(Bool.True, 42) } } diff --git a/test/examples/cases/catch-all.solc b/test/examples/cases/catch-all.solc index 9bead6153..a3fd9f8b1 100644 --- a/test/examples/cases/catch-all.solc +++ b/test/examples/cases/catch-all.solc @@ -1,14 +1,14 @@ data Bool = False | True; contract CatchAll { - function catchAll(x : Bool, y : Bool) -> Bool{ + public function catchAll(x : Bool, y : Bool) -> Bool{ match x, y { | Bool.True, Bool.True => return Bool.True; | z, w => return z; } } - function main() -> Bool { + public function main() -> Bool { catchAll(Bool.True, Bool.False) } } diff --git a/test/examples/cases/closure-free-var-local.solc b/test/examples/cases/closure-free-var-local.solc index 34761aba0..1292f7497 100644 --- a/test/examples/cases/closure-free-var-local.solc +++ b/test/examples/cases/closure-free-var-local.solc @@ -7,7 +7,7 @@ function test() -> word { } contract C { - function main() -> word { + public function main() -> word { return test(); } } diff --git a/test/examples/cases/closure-free-var-std.solc b/test/examples/cases/closure-free-var-std.solc index 711d5bcba..8ce806b83 100644 --- a/test/examples/cases/closure-free-var-std.solc +++ b/test/examples/cases/closure-free-var-std.solc @@ -4,11 +4,11 @@ pragma no-coverage-condition ; pragma no-bounded-variable-condition ; contract Bug { - function main() -> word { + public function main() -> word { return makeClosure(42); } - function makeClosure(e : word) -> word { + public function makeClosure(e : word) -> word { let f = lam (x : word) { return e + x; // Uses Add.add typeclass method }; diff --git a/test/examples/cases/closure-free-var.solc b/test/examples/cases/closure-free-var.solc index edc5c7fcd..5e28f7312 100644 --- a/test/examples/cases/closure-free-var.solc +++ b/test/examples/cases/closure-free-var.solc @@ -15,11 +15,11 @@ instance word:Add { } contract Bug { - function main() -> word { + public function main() -> word { return makeClosure(42); } - function makeClosure(e : word) -> word { + public function makeClosure(e : word) -> word { let f = lam (x : word) { return Add.add(x,e); // this crashes // return addW(e,x); // this works diff --git a/test/examples/cases/comparisons.solc b/test/examples/cases/comparisons.solc index ef128308e..98608204b 100644 --- a/test/examples/cases/comparisons.solc +++ b/test/examples/cases/comparisons.solc @@ -13,5 +13,5 @@ function f(x: word, y:word) -> bool { } contract Comparisons { - function main() -> bool { return f(0,1); } + public function main() -> bool { return f(0,1); } } diff --git a/test/examples/cases/complexproxy.solc b/test/examples/cases/complexproxy.solc index d0c4af20c..54ca326ea 100644 --- a/test/examples/cases/complexproxy.solc +++ b/test/examples/cases/complexproxy.solc @@ -29,7 +29,7 @@ forall t. function morefun(p:Proxy(t)) -> word { } contract TestMemoryType { - function main() -> word { + public function main() -> word { return BaseMemoryType.memorySize(Proxy:Proxy( (word,word) )); } } diff --git a/test/examples/cases/compose_desugared.solc b/test/examples/cases/compose_desugared.solc index da0929fa0..303c3b030 100644 --- a/test/examples/cases/compose_desugared.solc +++ b/test/examples/cases/compose_desugared.solc @@ -37,7 +37,7 @@ forall a . instance t_id3(a) : invokable(a,a) { } contract Foo { - function main() -> word { + public function main() -> word { let f = compose(t_id3, t_id3); return invokable.invoke(f, 0); } diff --git a/test/examples/cases/const-array.solc b/test/examples/cases/const-array.solc index 3c83289e9..17a2fcecf 100644 --- a/test/examples/cases/const-array.solc +++ b/test/examples/cases/const-array.solc @@ -102,7 +102,7 @@ forall size elem . size : ToWord, elem:MemoryType => instance memory(array(size, contract Array { - function main() { + public function main() { let arr : memory(array(Succ(Succ(Succ(Succ(Zero)))), word)) = memory(42); // = (1,2,3,4,5,6,7,8,9,10); IndexAccessible.set(arr, 4, 33); diff --git a/test/examples/cases/const.solc b/test/examples/cases/const.solc index 2672a2725..0871138b8 100644 --- a/test/examples/cases/const.solc +++ b/test/examples/cases/const.solc @@ -3,7 +3,7 @@ function constApplied(x : word, y : word) -> word { } contract Foo { - function main () -> word { + public function main () -> word { return constApplied(0,1); } } diff --git a/test/examples/cases/copytomem.solc b/test/examples/cases/copytomem.solc index ac9a5ba94..b37fb5b8e 100644 --- a/test/examples/cases/copytomem.solc +++ b/test/examples/cases/copytomem.solc @@ -7,7 +7,7 @@ function copyToMem(reader:MemoryWordReader, dst:word, cnt: word) -> () { } contract Main { - function main() -> () { + public function main() -> () { let r : MemoryWordReader = MemoryWordReader(42); copyToMem(r, 0, 32); } diff --git a/test/examples/cases/cyclical-defs-inferred.solc b/test/examples/cases/cyclical-defs-inferred.solc index 9a185c79a..4304a96b5 100644 --- a/test/examples/cases/cyclical-defs-inferred.solc +++ b/test/examples/cases/cyclical-defs-inferred.solc @@ -6,7 +6,7 @@ function bar(x : word) -> word { } contract C { - function main() -> word { + public function main() -> word { return foo(1); } } diff --git a/test/examples/cases/cyclical-defs.solc b/test/examples/cases/cyclical-defs.solc index 512dab474..9c31ed615 100644 --- a/test/examples/cases/cyclical-defs.solc +++ b/test/examples/cases/cyclical-defs.solc @@ -6,13 +6,13 @@ function bar(x : word) -> word { } contract C { - function m(x : word) -> word { + public function m(x : word) -> word { return n(x); } - function n(x : word) -> word { + public function n(x : word) -> word { return m(x); } - function main() -> word { + public function main() -> word { return m(1); } } diff --git a/test/examples/cases/dispatch.solc b/test/examples/cases/dispatch.solc index 7f323878c..321eb9c46 100644 --- a/test/examples/cases/dispatch.solc +++ b/test/examples/cases/dispatch.solc @@ -253,13 +253,13 @@ instance C_Add2_Selector:Selector { // transform contract C { - function add2(x : word, y : word) -> word { + public function add2(x : word, y : word) -> word { let ret : word; assembly { ret := add(x,y) } return ret; } - function main() -> word { + public function main() -> word { let c = Contract( Method(C_Add2_Selector, Proxy : Proxy((word,word)), Proxy : Proxy(word), add2), Fallback(Proxy : Proxy(()),Proxy : Proxy(()),revert_handler) diff --git a/test/examples/cases/false-redundant-warning.solc b/test/examples/cases/false-redundant-warning.solc index 06b91b0b9..88f95679f 100644 --- a/test/examples/cases/false-redundant-warning.solc +++ b/test/examples/cases/false-redundant-warning.solc @@ -9,7 +9,7 @@ function test(x : Bool, y : Bool) -> Bool { } contract FalseRedundantWarning { - function main() -> Bool { + public function main() -> Bool { test(Bool.False, Bool.True) } } diff --git a/test/examples/cases/field-access.solc b/test/examples/cases/field-access.solc index 699900d85..b53e151ff 100644 --- a/test/examples/cases/field-access.solc +++ b/test/examples/cases/field-access.solc @@ -3,16 +3,16 @@ import std.{*}; contract PoC { field : word; - function set_x(b: bool) -> bool { + public function set_x(b: bool) -> bool { field = b; // BUG: `word` shouldn't be unified with `bool`. return b; } - function init(foo: bool) -> () { + public function init(foo: bool) -> () { field = 2; } - function main () -> () { + public function main () -> () { } } diff --git a/test/examples/cases/field-helper-cxt-collision.solc b/test/examples/cases/field-helper-cxt-collision.solc index ddf7a60c7..994f6568c 100644 --- a/test/examples/cases/field-helper-cxt-collision.solc +++ b/test/examples/cases/field-helper-cxt-collision.solc @@ -8,7 +8,7 @@ data FooCxt = FooCxt; contract Foo { x: word; - function get() -> word { + public function get() -> word { return x; } } diff --git a/test/examples/cases/field-name-error.solc b/test/examples/cases/field-name-error.solc index d810cf8bf..fd1bc3c5e 100644 --- a/test/examples/cases/field-name-error.solc +++ b/test/examples/cases/field-name-error.solc @@ -6,7 +6,7 @@ pragma no-bounded-variable-condition ; contract PoC { x : word; - function main () -> word { + public function main () -> word { return 0; } } diff --git a/test/examples/cases/for-body-shadow.solc b/test/examples/cases/for-body-shadow.solc index 806cef6d4..dbe9d0047 100644 --- a/test/examples/cases/for-body-shadow.solc +++ b/test/examples/cases/for-body-shadow.solc @@ -1,7 +1,7 @@ import std.{Num,Add,Sub,Eq,Ord,Bounded,Typedef,le}; contract C { - function main() -> word { + public function main() -> word { let x = 100; let i = 0; let s = 0; diff --git a/test/examples/cases/for-init-shadow.solc b/test/examples/cases/for-init-shadow.solc index 2453a1cad..78d502d69 100644 --- a/test/examples/cases/for-init-shadow.solc +++ b/test/examples/cases/for-init-shadow.solc @@ -1,7 +1,7 @@ import std.{Num,Add,Sub,Eq,Ord,Bounded,Typedef,le}; contract Prefor { - function main() -> word { + public function main() -> word { let i = 100; let s = 0; for(let i=1;i<=10;i=i+1) { s = s + i; } diff --git a/test/examples/cases/for-inner-block.solc b/test/examples/cases/for-inner-block.solc index f21359c6f..8954a27aa 100644 --- a/test/examples/cases/for-inner-block.solc +++ b/test/examples/cases/for-inner-block.solc @@ -1,6 +1,6 @@ import std.{lt,Ord,Add,Sub,Bounded,Num,Eq,Typedef}; contract ForInner { - function main() -> word { + public function main() -> word { let result = 0; for (let height = 0; height < 7; height = height + 1) { if (true) { result = height; } else {} diff --git a/test/examples/cases/for-let-post.solc b/test/examples/cases/for-let-post.solc index ba0916066..9e75158e3 100644 --- a/test/examples/cases/for-let-post.solc +++ b/test/examples/cases/for-let-post.solc @@ -1,7 +1,7 @@ import std.{Num,Add,Sub,Eq,Ord,Bounded,Typedef,le}; contract C { - function main() -> word { + public function main() -> word { let i = 0; let s = 99; for(i=0;i<=0;let j=1) { s = j; i = i + 1; } diff --git a/test/examples/cases/for-let.solc b/test/examples/cases/for-let.solc index 6030e6e37..b64ef77e4 100644 --- a/test/examples/cases/for-let.solc +++ b/test/examples/cases/for-let.solc @@ -1,7 +1,7 @@ import std.{Num,Add,Sub,Eq,Ord,Bounded,Typedef,le}; contract Prefor { - function main() -> word { + public function main() -> word { let s = 0; for(let i=1;i<=10;i=i+1) { s = s + i;} diff --git a/test/examples/cases/for-loop.solc b/test/examples/cases/for-loop.solc index aaff7d2aa..d92167804 100644 --- a/test/examples/cases/for-loop.solc +++ b/test/examples/cases/for-loop.solc @@ -1,7 +1,7 @@ import std.{Num,Add,Sub,Eq,Ord,Bounded,Typedef,le}; contract Prefor { - function main() -> word { + public function main() -> word { let i:word; let s = 0; for(i=1;i<=10;i=i+1) { s = s + i;} diff --git a/test/examples/cases/fresh-pat-arg-synonym.solc b/test/examples/cases/fresh-pat-arg-synonym.solc index ade828c05..876e5bdae 100644 --- a/test/examples/cases/fresh-pat-arg-synonym.solc +++ b/test/examples/cases/fresh-pat-arg-synonym.solc @@ -4,7 +4,7 @@ function f(x:W) -> W { x } contract C { - function main () -> word { + public function main () -> word { return f(42); } } diff --git a/test/examples/cases/fresh-pat-arg.solc b/test/examples/cases/fresh-pat-arg.solc index 7d497afab..b7e0958b2 100644 --- a/test/examples/cases/fresh-pat-arg.solc +++ b/test/examples/cases/fresh-pat-arg.solc @@ -3,5 +3,5 @@ function g(x:word) -> word { x } forall a. function h(x:a) -> a { x } contract C { - function main() -> word { g(h(42)) } + public function main() -> word { g(h(42)) } } diff --git a/test/examples/cases/fresh-variable-shadowing.solc b/test/examples/cases/fresh-variable-shadowing.solc index c15b6e96a..930f81ba3 100644 --- a/test/examples/cases/fresh-variable-shadowing.solc +++ b/test/examples/cases/fresh-variable-shadowing.solc @@ -8,7 +8,7 @@ function test(v0 : Bool, p : Bool) -> Bool { } contract FreshVariableShadowing { - function main() -> Bool { + public function main() -> Bool { test(Bool.True, Bool.False) } } diff --git a/test/examples/cases/if-examples.solc b/test/examples/cases/if-examples.solc index 22e1c1373..a440c275d 100644 --- a/test/examples/cases/if-examples.solc +++ b/test/examples/cases/if-examples.solc @@ -37,7 +37,7 @@ function foo(x : word) -> bool { contract IfExamples { - function main() -> word { + public function main() -> word { return (if not(foo(42)) then 0 else 1); } } diff --git a/test/examples/cases/import-std.solc b/test/examples/cases/import-std.solc index 07a1a06b7..cbb62e40b 100644 --- a/test/examples/cases/import-std.solc +++ b/test/examples/cases/import-std.solc @@ -4,7 +4,7 @@ pragma no-coverage-condition ; pragma no-bounded-variable-condition ; contract Test { - function main() -> word { + public function main() -> word { return std.addWord(21, 21); } } diff --git a/test/examples/cases/inc-closure.solc b/test/examples/cases/inc-closure.solc index be7b46da3..c88f883e7 100644 --- a/test/examples/cases/inc-closure.solc +++ b/test/examples/cases/inc-closure.solc @@ -11,7 +11,7 @@ function inc(x : word) -> word { contract Foo { - function main () -> word { + public function main () -> word { return inc(0); } } diff --git a/test/examples/cases/instance-synonym-int.solc b/test/examples/cases/instance-synonym-int.solc index bc2c49d0a..39de4e1d3 100644 --- a/test/examples/cases/instance-synonym-int.solc +++ b/test/examples/cases/instance-synonym-int.solc @@ -11,7 +11,7 @@ instance word : Int { contract C { - function main () -> W { + public function main () -> W { let r : W = Int.fromWord(42); return r; } diff --git a/test/examples/cases/instance-synonym.solc b/test/examples/cases/instance-synonym.solc index ffa2543f2..17d1520d6 100644 --- a/test/examples/cases/instance-synonym.solc +++ b/test/examples/cases/instance-synonym.solc @@ -11,7 +11,7 @@ instance W:IdTy { } contract C { - function main() -> word { + public function main() -> word { return IdTy.id(42); } } diff --git a/test/examples/cases/join.solc b/test/examples/cases/join.solc index 848694f4e..e320eece0 100644 --- a/test/examples/cases/join.solc +++ b/test/examples/cases/join.solc @@ -2,14 +2,14 @@ contract Option { data Option(a) = None | Some(a); data Bool = False | True; - function maybe(n : word, o : Option(word)) -> word { + public function maybe(n : word, o : Option(word)) -> word { match o { | Option.None => return n; | Option.Some(x) => return x; } } - function join(mmx : Option(Option(word))) -> Option(word) { + public function join(mmx : Option(Option(word))) -> Option(word) { let result = Option.None; match mmx { | Option.Some(Option.Some(x)) => result = Option.Some(x); @@ -20,7 +20,7 @@ contract Option { return result; } - function main() -> word { + public function main() -> word { return maybe(0, join(Option.Some(Option.Some(0)))); } } diff --git a/test/examples/cases/joinErr.solc b/test/examples/cases/joinErr.solc index 842b34a8f..6ae546972 100644 --- a/test/examples/cases/joinErr.solc +++ b/test/examples/cases/joinErr.solc @@ -2,14 +2,14 @@ contract Option { data Option(a) = None | Some(a); data Bool = False | True; - function maybe(n : word, o : Option(word)) -> word { + public function maybe(n : word, o : Option(word)) -> word { match o { | Option.None => return n; | Option.Some(x) => return x; } } - function join(mmx : Option(Option(word))) -> Option(word) { + public function join(mmx : Option(Option(word))) -> Option(word) { let result = Option.None; match mmx { | Option.Some(Option.Some(x)) => result = Option.Some(x); @@ -19,7 +19,7 @@ contract Option { } - function main() -> word { + public function main() -> word { return maybe(0, join(Option.Some(Option.Some(Bool.False)))); } } diff --git a/test/examples/cases/ltimp.solc b/test/examples/cases/ltimp.solc index 571f800db..c31fc5f39 100644 --- a/test/examples/cases/ltimp.solc +++ b/test/examples/cases/ltimp.solc @@ -1,5 +1,5 @@ import ltproxy.{ltproxy}; contract LtImp { - function main() -> bool { ltproxy() } + public function main() -> bool { ltproxy() } } diff --git a/test/examples/cases/mainproxy.solc b/test/examples/cases/mainproxy.solc index 77a12b589..1e3f5c87f 100644 --- a/test/examples/cases/mainproxy.solc +++ b/test/examples/cases/mainproxy.solc @@ -16,7 +16,7 @@ function morefun(p:Proxy(t)) -> word { return BaseMemoryType.memorySize(Proxy:Pr } contract TestMemoryType { - function main() -> word { + public function main() -> word { return morefun(Proxy:Proxy(word)); } } diff --git a/test/examples/cases/match-compiler-undef-asm.solc b/test/examples/cases/match-compiler-undef-asm.solc index 2f7eebcde..28b89fdcc 100644 --- a/test/examples/cases/match-compiler-undef-asm.solc +++ b/test/examples/cases/match-compiler-undef-asm.solc @@ -13,7 +13,7 @@ forall a . function read(x : Foo(a)) -> word { contract Bla { - function main () -> word { + public function main () -> word { return read(Foo(42)); } } diff --git a/test/examples/cases/match-yul.solc b/test/examples/cases/match-yul.solc index 92989972b..a9fe458b0 100644 --- a/test/examples/cases/match-yul.solc +++ b/test/examples/cases/match-yul.solc @@ -1,9 +1,9 @@ data Wrapper = Wrapper(word); contract C { - function main() -> word { + public function main() -> word { return foo(Wrapper(1)); } - function foo(w:Wrapper) -> word { + public function foo(w:Wrapper) -> word { let result : word; match w { | Wrapper(ptr) => diff --git a/test/examples/cases/missing-instance.solc b/test/examples/cases/missing-instance.solc index 8d31f5985..1e1ca0eb2 100644 --- a/test/examples/cases/missing-instance.solc +++ b/test/examples/cases/missing-instance.solc @@ -17,7 +17,7 @@ instance word:MemoryType { } contract C { - function main() -> word { + public function main() -> word { let ptr = 0; // if we inline the let below into return then another bug occurs: main is typed as forall a. () -> a // let w:word = MemoryType.load(0); diff --git a/test/examples/cases/modifier.solc b/test/examples/cases/modifier.solc index aee26cfb9..ad6c50095 100644 --- a/test/examples/cases/modifier.solc +++ b/test/examples/cases/modifier.solc @@ -1,5 +1,5 @@ contract C { - function add(x: word, y:word) -> word { + public function add(x: word, y:word) -> word { let r : word; assembly { r := add(x, y) @@ -8,14 +8,14 @@ contract C { } // modifier pattern: wrap add with before/after code - function modifiedAdd(x : word, y : word) -> word { + public function modifiedAdd(x : word, y : word) -> word { // before solidity placeholder let result = add(x, y); // Solidity's placeholder: _; // after solidity placeholder return result; } - function main() -> word { + public function main() -> word { return modifiedAdd(2, 1); } } diff --git a/test/examples/cases/monomorphic-require.solc b/test/examples/cases/monomorphic-require.solc index a3777e20a..df7b1a2a9 100644 --- a/test/examples/cases/monomorphic-require.solc +++ b/test/examples/cases/monomorphic-require.solc @@ -25,12 +25,12 @@ function callvalue() -> uint256 { } contract Deposit { -function deposit() -> () { +public function deposit() -> () { require(callvalue() != uint256(0)); return (); } -function main() -> () { +public function main() -> () { deposit(); } } \ No newline at end of file diff --git a/test/examples/cases/multi-stmt-var-leaf.solc b/test/examples/cases/multi-stmt-var-leaf.solc index 758641f8e..aff2196ad 100644 --- a/test/examples/cases/multi-stmt-var-leaf.solc +++ b/test/examples/cases/multi-stmt-var-leaf.solc @@ -1,7 +1,7 @@ data Bool = False | True; contract MultiStmtVarLeaf { - function main(x:Bool) -> Bool { + public function main(x:Bool) -> Bool { match x { | y => let z = y; diff --git a/test/examples/cases/nano-desugared.solc b/test/examples/cases/nano-desugared.solc index 509d57451..055dc9f8e 100644 --- a/test/examples/cases/nano-desugared.solc +++ b/test/examples/cases/nano-desugared.solc @@ -405,28 +405,28 @@ data balances_sel = balances_sel ; instance StructField(ContractStorage(UintCxt), balances_sel) :CStructField(mapping(address, uint), (word, (address, (address, (uint, (uint, ())))))) { } contract Uint { - function mint (amount : uint) { + public function mint (amount : uint) { Assign.assign(LValueMemberAccess.memberAccess(IndexAccessProxy(LValueMemberAccess.memberAccess(MemberAccessProxy(ContractStorage(UintCxt), balances_sel)), rval(MemberAccessProxy(ContractStorage(UintCxt), owner_sel)))), Num.add(rval(IndexAccessProxy(LValueMemberAccess.memberAccess(MemberAccessProxy(ContractStorage(UintCxt), balances_sel)), rval(MemberAccessProxy(ContractStorage(UintCxt), owner_sel)))), amount)); Assign.assign(LValueMemberAccess.memberAccess(MemberAccessProxy(ContractStorage(UintCxt), totalSupply_sel)), Num.add(rval(MemberAccessProxy(ContractStorage(UintCxt), totalSupply_sel)), amount)); } - function transferFrom (src : address, dst : address, amt : uint) -> Bool { + public function transferFrom (src : address, dst : address, amt : uint) -> Bool { require1(ge(rval(IndexAccessProxy(LValueMemberAccess.memberAccess(MemberAccessProxy(ContractStorage(UintCxt), balances_sel)), src)), amt)); withdraw(src, amt); deposit(dst, amt); return Bool.True; } - function withdraw (src : address, amt : uint) { + public function withdraw (src : address, amt : uint) { Assign.assign(LValueMemberAccess.memberAccess(IndexAccessProxy(LValueMemberAccess.memberAccess(MemberAccessProxy(ContractStorage(UintCxt), balances_sel)), src)), Num.sub(rval(IndexAccessProxy(LValueMemberAccess.memberAccess(MemberAccessProxy(ContractStorage(UintCxt), balances_sel)), src)), amt) : uint); } - function deposit (dst : address, amt : uint) { + public function deposit (dst : address, amt : uint) { Assign.assign(LValueMemberAccess.memberAccess(IndexAccessProxy(LValueMemberAccess.memberAccess(MemberAccessProxy(ContractStorage(UintCxt), balances_sel)), dst)), Num.add(rval(IndexAccessProxy(LValueMemberAccess.memberAccess(MemberAccessProxy(ContractStorage(UintCxt), balances_sel)), dst)), amt) : uint); } - function init () { + public function init () { Assign.assign(LValueMemberAccess.memberAccess(MemberAccessProxy(ContractStorage(UintCxt), owner_sel)), address(81985529216486895)); Assign.assign(LValueMemberAccess.memberAccess(MemberAccessProxy(ContractStorage(UintCxt), msg_sender_sel)), caller()); Assign.assign(LValueMemberAccess.memberAccess(MemberAccessProxy(ContractStorage(UintCxt), decimals_sel)), Num.fromWord(18)); } - function main () -> uint { + public function main () -> uint { init(); mint(uint(1000)); mint(uint(1000)); diff --git a/test/examples/cases/noconstr.solc b/test/examples/cases/noconstr.solc index ef79dd9c1..286d0ee6f 100644 --- a/test/examples/cases/noconstr.solc +++ b/test/examples/cases/noconstr.solc @@ -11,7 +11,7 @@ function bla (x : a) -> word { } contract Test { - function main() { + public function main() { return bla(1); } } diff --git a/test/examples/cases/option2.solc b/test/examples/cases/option2.solc index 60ded56fc..b60d551d8 100644 --- a/test/examples/cases/option2.solc +++ b/test/examples/cases/option2.solc @@ -1,16 +1,16 @@ contract Option { data Option(a) = None | Some(a); - function just(x : word) -> Option(word) { return Option.Some(x); } + public function just(x : word) -> Option(word) { return Option.Some(x); } - function maybe(n : word, o : Option(word)) -> word { + public function maybe(n : word, o : Option(word)) -> word { match o { | Option.None => return n; | Option.Some(x) => return x; } } - function join(mmx : Option(Option(word))) -> Option(word) { + public function join(mmx : Option(Option(word))) -> Option(word) { match mmx { | Option.None => return Option.None; | Option.Some(Option.None) => return Option.None; @@ -18,7 +18,7 @@ contract Option { } } - function join2(mmx : Option(Option(word))) -> Option(word) { + public function join2(mmx : Option(Option(word))) -> Option(word) { match mmx { | Option.Some(m) => match m { | Option.None => return Option.None; @@ -28,7 +28,7 @@ contract Option { } } - function main() -> word { + public function main() -> word { // return maybe(0, join(Option.Some(Option.Some(42)))); return 42; } diff --git a/test/examples/cases/pars.solc b/test/examples/cases/pars.solc index d389bac47..ccb6d3867 100644 --- a/test/examples/cases/pars.solc +++ b/test/examples/cases/pars.solc @@ -1,3 +1,3 @@ contract Pars { - function main() -> (){ let f:word; 42; (); } + public function main() -> (){ let f:word; 42; (); } } diff --git a/test/examples/cases/phantom-type-return-con.solc b/test/examples/cases/phantom-type-return-con.solc index b4f75b97a..87ae13647 100644 --- a/test/examples/cases/phantom-type-return-con.solc +++ b/test/examples/cases/phantom-type-return-con.solc @@ -10,7 +10,7 @@ data Foo(a) = Foo(word); } contract C { - function main() -> word { + public function main() -> word { return unwrap(); } } diff --git a/test/examples/cases/polymatch-error.solc b/test/examples/cases/polymatch-error.solc index 1c27cbda5..96462fd73 100644 --- a/test/examples/cases/polymatch-error.solc +++ b/test/examples/cases/polymatch-error.solc @@ -4,7 +4,7 @@ forall a b . function fst(p: (a, b)) -> a { } } contract TestUnitMatch { - function main() -> () { + public function main() -> () { match ((), ()) { | x => return fst(x); } diff --git a/test/examples/cases/polymorphic-require.solc b/test/examples/cases/polymorphic-require.solc index b89dec7ef..dbab329e2 100644 --- a/test/examples/cases/polymorphic-require.solc +++ b/test/examples/cases/polymorphic-require.solc @@ -21,12 +21,12 @@ function callvalue() -> uint256 { } contract Deposit { -function deposit() -> () { +public function deposit() -> () { require(callvalue() != uint256(0)); return (); } -function main() -> () { +public function main() -> () { deposit(); } } \ No newline at end of file diff --git a/test/examples/cases/public-constructor.solc b/test/examples/cases/public-constructor.solc new file mode 100644 index 000000000..99728d164 --- /dev/null +++ b/test/examples/cases/public-constructor.solc @@ -0,0 +1,10 @@ +import std.{*}; +import std.dispatch.{*}; + +contract PublicConstructor { + public constructor() {} + + public function answer() -> uint256 { + return uint256(42); + } +} diff --git a/test/examples/cases/public-fallback.solc b/test/examples/cases/public-fallback.solc new file mode 100644 index 000000000..a4a378214 --- /dev/null +++ b/test/examples/cases/public-fallback.solc @@ -0,0 +1,10 @@ +import std.{*}; +import std.dispatch.{*}; + +contract PublicFallback { + constructor() {} + + public fallback() -> () { + revert("fallback-was-called"); + } +} diff --git a/test/examples/cases/redundant-match.solc b/test/examples/cases/redundant-match.solc index 35886130c..f7913c2b2 100644 --- a/test/examples/cases/redundant-match.solc +++ b/test/examples/cases/redundant-match.solc @@ -9,5 +9,5 @@ data Bool = False | True; } contract Test { - function main() -> Bool { f(Bool.True) } + public function main() -> Bool { f(Bool.True) } } diff --git a/test/examples/cases/reference-encoding-good.solc b/test/examples/cases/reference-encoding-good.solc index 1c9f9f83b..e7a28b030 100644 --- a/test/examples/cases/reference-encoding-good.solc +++ b/test/examples/cases/reference-encoding-good.solc @@ -227,7 +227,7 @@ function g() -> () { Assign.assign(LValueMemberAccess.memberAccess(MemberAccessProxy(s, z_sel)), RValueMemberAccess.memberAccess(MemberAccessProxy(s, x_sel))); } contract C { - function main() -> () { + public function main() -> () { f(); g(); } diff --git a/test/examples/cases/reference-encoding-good1.solc b/test/examples/cases/reference-encoding-good1.solc index 4375d7ee9..393751b4e 100644 --- a/test/examples/cases/reference-encoding-good1.solc +++ b/test/examples/cases/reference-encoding-good1.solc @@ -228,7 +228,7 @@ function g() -> () { Assign.assign(LValueMemberAccess.memberAccess(MemberAccessProxy(s, z_sel)), RValueMemberAccess.memberAccess(MemberAccessProxy(s, x_sel))); } contract C { - function main() -> () { + public function main() -> () { f(); g(); } diff --git a/test/examples/cases/reference-encoding.solc b/test/examples/cases/reference-encoding.solc index 8bd6a910d..c81438722 100644 --- a/test/examples/cases/reference-encoding.solc +++ b/test/examples/cases/reference-encoding.solc @@ -220,7 +220,7 @@ function g() { Assign.assign(LValueMemberAccess.memberAccess(MemberAccessProxy(s, z_sel)), RValueMemberAccess.memberAccess(MemberAccessProxy(s, x_sel))); } contract C { - function main() { + public function main() { f(); g(); } diff --git a/test/examples/cases/reference-test.solc b/test/examples/cases/reference-test.solc index f94200ac6..a7922668c 100644 --- a/test/examples/cases/reference-test.solc +++ b/test/examples/cases/reference-test.solc @@ -47,7 +47,7 @@ forall abs rep . test(abs):Typedef(rep), rep:Test => } contract C { - function main() { + public function main() { let x:test(word) = test(memory(42)); let ptr:word = Test.test(x); } diff --git a/test/examples/cases/reference.solc b/test/examples/cases/reference.solc index 861516cfa..23c8e63f5 100644 --- a/test/examples/cases/reference.solc +++ b/test/examples/cases/reference.solc @@ -18,7 +18,7 @@ forall r : Ref (a,b) . instance XRef(r, PairFst, a) : Ref(a) {} forall r : Ref (a,b) . instance XRef(r, PairSnd, b) : Ref(b) {} contract AssignNested { - function main() { + public function main() { let x : stack( (word, (word, word)) ); let z : stack( (word, (word, word)) ); diff --git a/test/examples/cases/references-daniel.solc b/test/examples/cases/references-daniel.solc index c5dd9d6fb..c5d2657fb 100644 --- a/test/examples/cases/references-daniel.solc +++ b/test/examples/cases/references-daniel.solc @@ -229,7 +229,7 @@ function g() { } contract C { - function main() { + public function main() { f(); g(); } diff --git a/test/examples/cases/require-annotation-contract-method.solc b/test/examples/cases/require-annotation-contract-method.solc index 9009e6740..55bd20051 100644 --- a/test/examples/cases/require-annotation-contract-method.solc +++ b/test/examples/cases/require-annotation-contract-method.solc @@ -1,10 +1,10 @@ // Error: contract method missing return type annotation contract Doubler { - function double(x : word) { + public function double(x : word) { return x; } - function main() -> word { + public function main() -> word { return double(21); } } diff --git a/test/examples/cases/simpleDiscount.solc b/test/examples/cases/simpleDiscount.solc index f4584a12a..ebafe1b08 100644 --- a/test/examples/cases/simpleDiscount.solc +++ b/test/examples/cases/simpleDiscount.solc @@ -20,7 +20,7 @@ function discount(state : AuctionState, phase : Phase) -> word { } contract Discount { - function main() -> word { + public function main() -> word { discount(.Active(420,.address(0)), .Early) } } diff --git a/test/examples/cases/simpleIfExpr.solc b/test/examples/cases/simpleIfExpr.solc index 53b0d57e0..a6c812a8b 100644 --- a/test/examples/cases/simpleIfExpr.solc +++ b/test/examples/cases/simpleIfExpr.solc @@ -1,3 +1,3 @@ contract SimpleIfStmt { - function main() { return (if (true) then 1 else 0); } + public function main() { return (if (true) then 1 else 0); } } diff --git a/test/examples/cases/simpleIfStmt.solc b/test/examples/cases/simpleIfStmt.solc index ab9d49dda..80e672f27 100644 --- a/test/examples/cases/simpleIfStmt.solc +++ b/test/examples/cases/simpleIfStmt.solc @@ -1,3 +1,3 @@ contract SimpleIfStmt { - function main() { if (true) {return 1;} else {return 0;} } + public function main() { if (true) {return 1;} else {return 0;} } } diff --git a/test/examples/cases/skolem-let.solc b/test/examples/cases/skolem-let.solc index 2e19b6328..2f8ea1c6d 100644 --- a/test/examples/cases/skolem-let.solc +++ b/test/examples/cases/skolem-let.solc @@ -6,7 +6,7 @@ forall a. function fromWord(x: word) -> a { } contract Unsafe { - function main() { + public function main() { fromWord(7):(); return 42; } diff --git a/test/examples/cases/string-const.solc b/test/examples/cases/string-const.solc index 204fb34ee..735a6d6f9 100644 --- a/test/examples/cases/string-const.solc +++ b/test/examples/cases/string-const.solc @@ -1,5 +1,5 @@ contract Answer { - function main() { + public function main() { return "42"; } } diff --git a/test/examples/cases/subject-index.solc b/test/examples/cases/subject-index.solc index 0ca15321a..667f65e50 100644 --- a/test/examples/cases/subject-index.solc +++ b/test/examples/cases/subject-index.solc @@ -71,7 +71,7 @@ instance StructField(MintCtx, balances_sel):CStructField(mapping(word,word), ()) } contract Map { - function main () { + public function main () { mint(1000); } } diff --git a/test/examples/cases/subsumption-constraint.solc b/test/examples/cases/subsumption-constraint.solc index 6bfc0cec5..bf0cd6b51 100644 --- a/test/examples/cases/subsumption-constraint.solc +++ b/test/examples/cases/subsumption-constraint.solc @@ -10,13 +10,13 @@ forall a . function the_bug(x : a, y : a) -> Bool { } contract Foo { - function x() { + public function x() { let b1 = Bool.True; let b2 = Bool.False; the_bug(b1, b2); } - function main() { + public function main() { x(); } } diff --git a/test/examples/cases/sum-match-default.solc b/test/examples/cases/sum-match-default.solc index e0a397861..fb90bf701 100644 --- a/test/examples/cases/sum-match-default.solc +++ b/test/examples/cases/sum-match-default.solc @@ -1,14 +1,14 @@ contract SumMatchDefault { data Option(a) = None | Some(a); - function g(s : Option(word)) -> Option(word) { + public function g(s : Option(word)) -> Option(word) { match s { | Option.None => return Option.None; | x => return x; } } - function main() -> word { + public function main() -> word { g(Option.None); return 42; } diff --git a/test/examples/cases/synonym-recursive.solc b/test/examples/cases/synonym-recursive.solc index ae490f920..3e34ef4c2 100644 --- a/test/examples/cases/synonym-recursive.solc +++ b/test/examples/cases/synonym-recursive.solc @@ -2,7 +2,7 @@ type A = B; type B = A; contract RecursiveTest { - function main() -> word { + public function main() -> word { return 0; } } \ No newline at end of file diff --git a/test/examples/cases/td.solc b/test/examples/cases/td.solc index d6c380980..8b922c9dc 100644 --- a/test/examples/cases/td.solc +++ b/test/examples/cases/td.solc @@ -15,5 +15,5 @@ function lift1ac(f:(rep) -> res, x:abs) -> res { f(Typedef.rep(x)) } forall a. function id(x:a) -> a {x} contract TD { - function main() -> word { lift1ac(id, 42) } + public function main() -> word { lift1ac(id, 42) } } diff --git a/test/examples/cases/tiamat.solc b/test/examples/cases/tiamat.solc index 5dd2dfe87..8a0c971c9 100644 --- a/test/examples/cases/tiamat.solc +++ b/test/examples/cases/tiamat.solc @@ -127,7 +127,7 @@ instance storage(a):Assign(a) { } contract Tiamat { - function main() -> word { + public function main() -> word { let allowances : storage(dict(address, dict(address, word))); let src = address(17); setAllowance(allowances, address(1),address(2), 666); diff --git a/test/examples/cases/tuple-trick.solc b/test/examples/cases/tuple-trick.solc index cdad52de8..0de688ce9 100644 --- a/test/examples/cases/tuple-trick.solc +++ b/test/examples/cases/tuple-trick.solc @@ -27,10 +27,10 @@ forall n a b c . n : Nth (b,c) => instance Succ(n) : Nth ((a,b), c) { } contract C { - function id (x : word) -> word { + public function id (x : word) -> word { return x; } - function main () -> () { + public function main () -> () { let p : (word, word, word, ()); let x : word = Nth.nth(Proxy : Proxy(Zero), p); let y : word = Nth.nth(Proxy : Proxy(Succ(Zero)), p); diff --git a/test/examples/cases/tuva.solc b/test/examples/cases/tuva.solc index 2a0b6682b..31bb144bc 100644 --- a/test/examples/cases/tuva.solc +++ b/test/examples/cases/tuva.solc @@ -61,7 +61,7 @@ function idx_lval(x:r) -> a { } contract TestTuva { - function main() -> word { + public function main() -> word { let balances : storage(mapping(address, word)); let allowances : storage(mapping(address, mapping(address, word) )); let ref1 : storage(word) = idx_lval( (balances, address(17)) ); diff --git a/test/examples/cases/type-synonym-arg.solc b/test/examples/cases/type-synonym-arg.solc index ade828c05..876e5bdae 100644 --- a/test/examples/cases/type-synonym-arg.solc +++ b/test/examples/cases/type-synonym-arg.solc @@ -4,7 +4,7 @@ function f(x:W) -> W { x } contract C { - function main () -> word { + public function main () -> word { return f(42); } } diff --git a/test/examples/cases/uintdesugared.solc b/test/examples/cases/uintdesugared.solc index 5961d67e3..b28a26db4 100644 --- a/test/examples/cases/uintdesugared.solc +++ b/test/examples/cases/uintdesugared.solc @@ -494,15 +494,15 @@ data balances_sel = balances_sel ; instance StructField(ContractStorage(UintCxt), balances_sel) :CStructField(mapping(address, uint), (word, (address, (uint, (uint, ()))))) { } contract Uint { - function mint (amount : uint) -> () { + public function mint (amount : uint) -> () { Assign.assign(LValueMemberAccess.memberAccess(IndexAccessProxy(LValueMemberAccess.memberAccess(MemberAccessProxy(ContractStorage(UintCxt), balances_sel)), rval(MemberAccessProxy(ContractStorage(UintCxt), owner_sel)))), Num.add(rval(IndexAccessProxy(LValueMemberAccess.memberAccess(MemberAccessProxy(ContractStorage(UintCxt), balances_sel)), rval(MemberAccessProxy(ContractStorage(UintCxt), owner_sel)))), amount)); Assign.assign(LValueMemberAccess.memberAccess(MemberAccessProxy(ContractStorage(UintCxt), totalSupply_sel)), Num.add(rval(MemberAccessProxy(ContractStorage(UintCxt), totalSupply_sel)), amount)); } - function init () -> () { + public function init () -> () { Assign.assign(LValueMemberAccess.memberAccess(MemberAccessProxy(ContractStorage(UintCxt), owner_sel)), address(81985529216486895)); Assign.assign(LValueMemberAccess.memberAccess(MemberAccessProxy(ContractStorage(UintCxt), decimals_sel)), Num.fromWord(18)); } - function main () -> uint { + public function main () -> uint { init(); mint(uint(1000)); mint(uint(1000)); diff --git a/test/examples/cases/undefined.solc b/test/examples/cases/undefined.solc index 9adc364c4..38e05d12e 100644 --- a/test/examples/cases/undefined.solc +++ b/test/examples/cases/undefined.solc @@ -7,7 +7,7 @@ forall any.function undefined() -> any { function useWord(w:word) -> () {} contract Magic { - function main() -> () { + public function main() -> () { useWord(undefined()); } } diff --git a/test/examples/cases/unit.solc b/test/examples/cases/unit.solc index 33b8ed206..98e93ae72 100644 --- a/test/examples/cases/unit.solc +++ b/test/examples/cases/unit.solc @@ -1,23 +1,23 @@ contract Unit { -function one (x : ()) -> word { +public function one (x : ()) -> word { return 1; } -function unitVal() -> () { +public function unitVal() -> () { return (); } -function unitMatch (x : ()) -> word { +public function unitMatch (x : ()) -> word { match x { | () => return 1; } } -function foo (x : word) -> () { +public function foo (x : word) -> () { return (); } -function main() -> word { +public function main() -> word { return unitMatch(foo(one(unitVal()))); } } diff --git a/test/examples/cases/word-match-default.solc b/test/examples/cases/word-match-default.solc index f1f42bc97..c1b17b956 100644 --- a/test/examples/cases/word-match-default.solc +++ b/test/examples/cases/word-match-default.solc @@ -1,5 +1,5 @@ contract WordMatchDefault { - function f(n : word) -> word { + public function f(n : word) -> word { let result : word; match n { | 0 => assembly { result := 100 } @@ -8,7 +8,7 @@ contract WordMatchDefault { return result; } - function main() -> word { + public function main() -> word { return f(42); } } diff --git a/test/examples/cases/xref.solc b/test/examples/cases/xref.solc index f8ec20ef6..d3cc27d2f 100644 --- a/test/examples/cases/xref.solc +++ b/test/examples/cases/xref.solc @@ -112,7 +112,7 @@ forall a b r . r:MemoryRef ((a,b)), a:MemoryType, b:MemoryType => instance XRef( } contract Ref219 { - function main() { + public function main() { let mp:M((word, word, word)) = M(96); // no alloc yet let p = (1,16,25); Ref.store(mp, p); diff --git a/test/examples/cases/yul-asm-for-body.solc b/test/examples/cases/yul-asm-for-body.solc index 3c15979d3..c928aec9d 100644 --- a/test/examples/cases/yul-asm-for-body.solc +++ b/test/examples/cases/yul-asm-for-body.solc @@ -10,7 +10,7 @@ function yul_asm_for_body() -> () { } contract Foo { - function main() -> () { + public function main() -> () { yul_asm_for_body() } } diff --git a/test/examples/cases/yul-asm-switch-body.solc b/test/examples/cases/yul-asm-switch-body.solc index 868d4dbce..1f91542d9 100644 --- a/test/examples/cases/yul-asm-switch-body.solc +++ b/test/examples/cases/yul-asm-switch-body.solc @@ -11,7 +11,7 @@ function yul_asm_switch_body() -> () { } contract Foo { - function main() -> () { + public function main() -> () { yul_asm_switch_body() } } diff --git a/test/examples/cases/yul-deposit-example.solc b/test/examples/cases/yul-deposit-example.solc index fa00becbf..150a5487a 100644 --- a/test/examples/cases/yul-deposit-example.solc +++ b/test/examples/cases/yul-deposit-example.solc @@ -8,7 +8,7 @@ function deposit(pubkey: memory(string), withdrawal_credentials: memory(string), } contract Foo { - function main () -> () { + public function main () -> () { deposit(memory(0), memory(0), memory(0), uint256(2)); } } diff --git a/test/examples/cases/yul-for.solc b/test/examples/cases/yul-for.solc index 642bfb196..55f3c00b0 100644 --- a/test/examples/cases/yul-for.solc +++ b/test/examples/cases/yul-for.solc @@ -1,5 +1,5 @@ contract YulFor { - function main() -> word { + public function main() -> word { let loopStart = 128; let loopEnd = 256; let res : word; diff --git a/test/examples/cases/yul-return.solc b/test/examples/cases/yul-return.solc index 95d1631b0..d1fbe38eb 100644 --- a/test/examples/cases/yul-return.solc +++ b/test/examples/cases/yul-return.solc @@ -1,5 +1,5 @@ contract C { - function main() -> () { + public function main() -> () { assembly { return(0,0); } diff --git a/test/examples/comptime/CondExpr.solc b/test/examples/comptime/CondExpr.solc index 6eff9a0a9..a2fac7f53 100644 --- a/test/examples/comptime/CondExpr.solc +++ b/test/examples/comptime/CondExpr.solc @@ -8,5 +8,5 @@ function notAnswer(n : word) -> word { if(n == 42) then 0 else 42 } function answer(n:word) -> word { notAnswer(notAnswer(42)) } contract Fib { - function main() -> word { answer(42) } + public function main() -> word { answer(42) } } diff --git a/test/examples/comptime/CondStmt.solc b/test/examples/comptime/CondStmt.solc index b86d24e21..c0bb72f08 100644 --- a/test/examples/comptime/CondStmt.solc +++ b/test/examples/comptime/CondStmt.solc @@ -11,7 +11,7 @@ function answer(n:word) -> word { return notAnswer(notAnswer(42)); } contract Fib { -function main() -> word { +public function main() -> word { return answer(42); } } diff --git a/test/examples/comptime/OneTwo.solc b/test/examples/comptime/OneTwo.solc index 7cba4bc32..7999abba6 100644 --- a/test/examples/comptime/OneTwo.solc +++ b/test/examples/comptime/OneTwo.solc @@ -23,6 +23,6 @@ function two () -> word { } contract OneTwo { - function main() -> word { return two(); } + public function main() -> word { return two(); } } diff --git a/test/examples/comptime/Plus.solc b/test/examples/comptime/Plus.solc index 7399c4d3e..2d34d846f 100644 --- a/test/examples/comptime/Plus.solc +++ b/test/examples/comptime/Plus.solc @@ -18,5 +18,5 @@ function two () -> word { } contract Plus { - function main() -> word { return two() + two(); } + public function main() -> word { return two() + two(); } } diff --git a/test/examples/comptime/Size.solc b/test/examples/comptime/Size.solc index c28bf6dec..7acf21fef 100644 --- a/test/examples/comptime/Size.solc +++ b/test/examples/comptime/Size.solc @@ -43,7 +43,7 @@ forall a b. a:StorageSize, b:StorageSize => instance (a,b):StorageSize { contract Size { - function main() -> word { + public function main() -> word { return StorageSize.size(Proxy:Proxy( (word, (word, ())))); } } diff --git a/test/examples/comptime/StdSize.solc b/test/examples/comptime/StdSize.solc index 534079b14..8d9a98e14 100644 --- a/test/examples/comptime/StdSize.solc +++ b/test/examples/comptime/StdSize.solc @@ -42,7 +42,7 @@ instance (a, b):StorageSize { } contract Size { - function main() -> word { + public function main() -> word { return StorageSize.size(Proxy:Proxy((word, (word, ())))); } } diff --git a/test/examples/comptime/counter.solc b/test/examples/comptime/counter.solc index 428de4be1..8c93f43e7 100644 --- a/test/examples/comptime/counter.solc +++ b/test/examples/comptime/counter.solc @@ -18,7 +18,7 @@ contract Counter { fld0 = 7; } - function main() -> word { + public function main() -> word { counter = counter + 1; return counter; } diff --git a/test/examples/comptime/fib.solc b/test/examples/comptime/fib.solc index 3da1cacfb..46498180f 100644 --- a/test/examples/comptime/fib.solc +++ b/test/examples/comptime/fib.solc @@ -8,7 +8,7 @@ function fib(n : word) -> word { } contract Fib { -function main() -> word { +public function main() -> word { return fib(10); } } diff --git a/test/examples/comptime/string-lit-keccak.solc b/test/examples/comptime/string-lit-keccak.solc index 101e86372..5d950e41e 100644 --- a/test/examples/comptime/string-lit-keccak.solc +++ b/test/examples/comptime/string-lit-keccak.solc @@ -4,7 +4,7 @@ pragma no-coverage-condition ; pragma no-bounded-variable-condition ; contract StringLitKeccak { - function main() -> word { + public function main() -> word { // keccakLit folds to a 256-bit word (EVM/Yul semantics) return std.keccakLit("abc"); } diff --git a/test/examples/comptime/string-lit-len.solc b/test/examples/comptime/string-lit-len.solc index 996931ad9..06a1a8e12 100644 --- a/test/examples/comptime/string-lit-len.solc +++ b/test/examples/comptime/string-lit-len.solc @@ -4,7 +4,7 @@ pragma no-coverage-condition ; pragma no-bounded-variable-condition ; contract StringLitLen { - function main() -> word { + public function main() -> word { // strlenLit folds to a word return std.strlenLit("hello"); } diff --git a/test/examples/comptime/string-lit-ops.solc b/test/examples/comptime/string-lit-ops.solc index 8a1d7abfe..6d09664b7 100644 --- a/test/examples/comptime/string-lit-ops.solc +++ b/test/examples/comptime/string-lit-ops.solc @@ -6,7 +6,7 @@ pragma no-bounded-variable-condition ; // These functions are intended to be folded by MastEval at compile time. contract StringLitOps { - function main() -> () { + public function main() -> () { // concat folds to a string literal, enabling revert("...") lowering // cannot handle string variables yet // let s = concatLit("ab", "cd"); diff --git a/test/examples/dispatch/Revert.solc b/test/examples/dispatch/Revert.solc index 42e662162..e7554baf9 100644 --- a/test/examples/dispatch/Revert.solc +++ b/test/examples/dispatch/Revert.solc @@ -13,11 +13,11 @@ function my_revert() -> word { contract Foo { constructor() {} - function noAnswer() -> uint256 { + public function noAnswer() -> uint256 { return uint256(my_revert()); } - function answer() -> uint256 { + public function answer() -> uint256 { return uint256(42); } } diff --git a/test/examples/dispatch/basic.json b/test/examples/dispatch/basic.json index c4e276f29..5fb519593 100644 --- a/test/examples/dispatch/basic.json +++ b/test/examples/dispatch/basic.json @@ -117,6 +117,18 @@ "returndata":"4924aef0", "status": "failure" } + }, + { + "input": { + "text-calldata": "non-public hidden() must not be dispatched", + "calldata":"aef6d4b1", + "value": "0" + }, + "kind": "call", + "output": { + "returndata":"4924aef0", + "status": "failure" + } } ] } diff --git a/test/examples/dispatch/basic.solc b/test/examples/dispatch/basic.solc index cabfcda6f..c8ee6e078 100644 --- a/test/examples/dispatch/basic.solc +++ b/test/examples/dispatch/basic.solc @@ -7,25 +7,29 @@ pragma no-bounded-variable-condition ; contract C { constructor() {} - function nothing() -> () {} + public function nothing() -> () {} - function something() -> (uint256) { + public function something() -> (uint256) { return uint256(1); } - function add2(x : uint256, y : uint256) -> uint256 { + public function add2(x : uint256, y : uint256) -> uint256 { return Add.add(x,y); } - function add3(x : uint256, y : uint256, z : uint256) -> uint256 { + public function add3(x : uint256, y : uint256, z : uint256) -> uint256 { return Add.add(z, Add.add(x,y)); } - function id_bytes(b: memory(bytes)) -> memory(bytes) { + public function id_bytes(b: memory(bytes)) -> memory(bytes) { return b; } - function id_string(b: memory(string)) -> memory(string) { + public function id_string(b: memory(string)) -> memory(string) { return b; } + + function hidden() -> (uint256) { + return uint256(42); + } } diff --git a/test/examples/dispatch/counter.solc b/test/examples/dispatch/counter.solc index 225a38d94..898f51807 100644 --- a/test/examples/dispatch/counter.solc +++ b/test/examples/dispatch/counter.solc @@ -13,7 +13,7 @@ contract Counter { // fld0 = 7; } - function test() -> uint256 { + public function test() -> uint256 { counter = counter + uint256(1); return counter; } diff --git a/test/examples/dispatch/fallback.solc b/test/examples/dispatch/fallback.solc index 6ecd82ae9..8eb19dbb6 100644 --- a/test/examples/dispatch/fallback.solc +++ b/test/examples/dispatch/fallback.solc @@ -4,7 +4,7 @@ import std.dispatch.{*}; contract WithFallback { constructor() {} - function answer() -> uint256 { + public function answer() -> uint256 { return uint256(42); } diff --git a/test/examples/dispatch/fib.solc b/test/examples/dispatch/fib.solc index c1c795b4f..3c01cd4bb 100644 --- a/test/examples/dispatch/fib.solc +++ b/test/examples/dispatch/fib.solc @@ -6,7 +6,7 @@ function fib(n : word) -> word { contract Fib { constructor() {} - function test() -> uint256 { + public function test() -> uint256 { return uint256(fib(10)); } } diff --git a/test/examples/dispatch/miniERC20.solc b/test/examples/dispatch/miniERC20.solc index edd303f59..e7455ea83 100644 --- a/test/examples/dispatch/miniERC20.solc +++ b/test/examples/dispatch/miniERC20.solc @@ -30,41 +30,41 @@ contract MiniERC20 { mint(totalSupply_); } - function name() -> memory(string) { + public function name() -> memory(string) { return name; } - function symbol() -> memory(string) { + public function symbol() -> memory(string) { return symbol; } - function decimals() -> uint256 { + public function decimals() -> uint256 { return decimals; } - function allowance(owner_ : address, spender: address) -> uint256 { + public function allowance(owner_ : address, spender: address) -> uint256 { return allowance[owner_][spender]; // don't use "owner" here } - function balanceOf(account : address) -> uint256 { + public function balanceOf(account : address) -> uint256 { return balances[account]; } - function totalSupply() -> uint256 { + public function totalSupply() -> uint256 { return totalSupply; } // Note that this is not access guarded — the minting always goes to the owner - function mint(amount:uint256) -> () { + public function mint(amount:uint256) -> () { balances[owner] = Num.add(balances[owner], amount); totalSupply = Num.add(totalSupply, amount); } - function transfer(dst : address, amt : uint256) -> bool { + public function transfer(dst : address, amt : uint256) -> bool { return transferFrom(caller(), dst, amt); } - function transferFrom(src:address, dst:address, amt:uint256) -> bool { + public function transferFrom(src:address, dst:address, amt:uint256) -> bool { let msg_sender = caller(); require(balances[src] >= amt, Error(0xf4d678b8)); // InsufficientBalance() @@ -79,7 +79,7 @@ contract MiniERC20 { return true; } - function approve(usr: address, amt: uint256) -> bool { + public function approve(usr: address, amt: uint256) -> bool { let msg_sender = caller(); allowance[msg_sender][usr] = amt; // emit Approval(msg.sender, usr, amt); @@ -88,11 +88,11 @@ contract MiniERC20 { // testing - function getMyBalance() -> uint256 { + public function getMyBalance() -> uint256 { return balances[caller()]; } - function test() -> uint256 { + public function test() -> uint256 { approve(address(0), uint256(10)); transferFrom(caller(), address(0), uint256(958)); return getMyBalance(); diff --git a/test/examples/dispatch/neg.solc b/test/examples/dispatch/neg.solc index 243737052..ea2b63b4b 100644 --- a/test/examples/dispatch/neg.solc +++ b/test/examples/dispatch/neg.solc @@ -68,5 +68,5 @@ instance (a:Neg,b:Neg) => Pair(a,b):Neg { contract NegPair { constructor() {} - function negPair() -> uint256 { return uint256(fromB(pairfst(Neg.neg(Pair(B.F,B.T))))); } + public function negPair() -> uint256 { return uint256(fromB(pairfst(Neg.neg(Pair(B.F,B.T))))); } } diff --git a/test/examples/dispatch/ownable.solc b/test/examples/dispatch/ownable.solc index 758614435..8a4e3edf1 100644 --- a/test/examples/dispatch/ownable.solc +++ b/test/examples/dispatch/ownable.solc @@ -23,11 +23,11 @@ contract Ownable { } // named getOwner() instead of owner() to avoid collision with the field name - function getOwner() -> address { + public function getOwner() -> address { return owner; } - function changeOwner(newOwner : address) -> () { + public function changeOwner(newOwner : address) -> () { require(caller() == owner, Error(0x12b0c500)); // OwnableUnauthorizedAccount() owner = newOwner; } diff --git a/test/examples/dispatch/payable.solc b/test/examples/dispatch/payable.solc index 53127a042..294edc82c 100644 --- a/test/examples/dispatch/payable.solc +++ b/test/examples/dispatch/payable.solc @@ -4,7 +4,7 @@ import std.dispatch.{*}; contract PayableTest { constructor() {} - payable function deposit() -> uint256 { + public payable function deposit() -> uint256 { let value; assembly { value := callvalue() @@ -12,7 +12,7 @@ contract PayableTest { return uint256(value); } - function balance() -> uint256 { + public function balance() -> uint256 { let value; assembly { value := selfbalance() diff --git a/test/examples/dispatch/stringid.solc b/test/examples/dispatch/stringid.solc index ad74625b1..cb16c01c7 100644 --- a/test/examples/dispatch/stringid.solc +++ b/test/examples/dispatch/stringid.solc @@ -7,7 +7,7 @@ pragma no-bounded-variable-condition ; contract C { constructor() {} - function id(x:memory(string)) -> (memory(string)) { + public function id(x:memory(string)) -> (memory(string)) { let ptr : word = Typedef.rep(x); let len : word; let n1 : word; @@ -21,14 +21,14 @@ contract C { return x; } - function const_a() -> (memory(string)) { + public function const_a() -> (memory(string)) { let resPtr = allocate_memory(64); let payload = 0x7777777777777777777777777777777777777777777777777777777777777777; mstore(resPtr, 3); mstore(resPtr+32, payload); return memory(resPtr); } - function mylen(x:memory(string)) -> uint256 { + public function mylen(x:memory(string)) -> uint256 { let ptr : word = Typedef.rep(x); let l : word; let n1 : word; diff --git a/test/examples/invokable/021nid.solc b/test/examples/invokable/021nid.solc index baeb8224d..a8deffa32 100644 --- a/test/examples/invokable/021nid.solc +++ b/test/examples/invokable/021nid.solc @@ -1,15 +1,15 @@ contract Id1 { - function id(x) { + public function id(x) { return x ; } - function nid() { + public function nid() { return id; } - function const(x, y) { return x; } + public function const(x, y) { return x; } - function main() { + public function main() { return nid(42); } } diff --git a/test/examples/invokable/022nid-invoke.solc b/test/examples/invokable/022nid-invoke.solc index fc5994e94..81346bfef 100644 --- a/test/examples/invokable/022nid-invoke.solc +++ b/test/examples/invokable/022nid-invoke.solc @@ -16,7 +16,7 @@ instance IdToken(a) : Invokable(a,a) { } contract InvokeId { - function id(x) { + public function id(x) { return x ; } @@ -26,11 +26,11 @@ contract InvokeId { } */ - function nidimpl() { + public function nidimpl() { return IdToken; } - function main() { + public function main() { // Instead of: `return nid(42)` return invoke(nidimpl(), 42); } diff --git a/test/examples/invokable/024lamid.solc b/test/examples/invokable/024lamid.solc index b399e9299..f4e794d5c 100644 --- a/test/examples/invokable/024lamid.solc +++ b/test/examples/invokable/024lamid.solc @@ -1,10 +1,10 @@ contract Id1 { - function id(x) { + public function id(x) { return x ; } - function main() { + public function main() { let nid = lam(x) {return x;}; return nid(42); } diff --git a/test/examples/invokable/025lamid-invoke.solc b/test/examples/invokable/025lamid-invoke.solc index 72d278733..0697ad108 100644 --- a/test/examples/invokable/025lamid-invoke.solc +++ b/test/examples/invokable/025lamid-invoke.solc @@ -23,7 +23,7 @@ instance Lam0Token(a) : Invokable(a,a) { contract InvokeLam { -function main() { +public function main() { let nid = Lam0Token; return invoke(nid, 42); } diff --git a/test/examples/invokable/026capture.solc b/test/examples/invokable/026capture.solc index e5e1ed189..d8b198daa 100644 --- a/test/examples/invokable/026capture.solc +++ b/test/examples/invokable/026capture.solc @@ -38,7 +38,7 @@ instance Lam1Closure(a) : Invokable(a,Word) { contract InvokeCapLam { -function main() { +public function main() { let y = 42; let clos = Lam1Closure(y); diff --git a/test/examples/invokable/027retfun.solc b/test/examples/invokable/027retfun.solc index 398901999..7bdefb80b 100644 --- a/test/examples/invokable/027retfun.solc +++ b/test/examples/invokable/027retfun.solc @@ -31,13 +31,13 @@ instance Lam1Closure(a) : Invokable(a,Word) { contract InvokeCapLam { -function foo() { +public function foo() { let y = 42; let clos = Lam1Closure(y); return clos; } -function main() { +public function main() { return invoke(foo(), 17); } diff --git a/test/examples/invokable/028modifier.solc b/test/examples/invokable/028modifier.solc index 9f18b2359..2bedcba8f 100644 --- a/test/examples/invokable/028modifier.solc +++ b/test/examples/invokable/028modifier.solc @@ -80,7 +80,7 @@ function add1mod(f) { contract Modifier { -function main() { +public function main() { let barClos = add1mod(FooToken); return invoke(barClos, 39); } diff --git a/test/examples/invokable/031enum.solc b/test/examples/invokable/031enum.solc index fde619818..2d60aa401 100644 --- a/test/examples/invokable/031enum.solc +++ b/test/examples/invokable/031enum.solc @@ -44,7 +44,7 @@ instance (a:Enum) => FromEnumToken(a) : Invokable(a,Word) { } } contract RGB { - function main() { + public function main() { /* let x = fromEnum(Color.B); let y = fromEnum(Bool.True); diff --git a/test/examples/spec/00answer.solc b/test/examples/spec/00answer.solc index add23c0b5..ba55aa252 100644 --- a/test/examples/spec/00answer.solc +++ b/test/examples/spec/00answer.solc @@ -1,5 +1,5 @@ contract Answer { - function main() -> word { + public function main() -> word { return 42; } } \ No newline at end of file diff --git a/test/examples/spec/010answer.solc b/test/examples/spec/010answer.solc index f71126558..5699ce863 100644 --- a/test/examples/spec/010answer.solc +++ b/test/examples/spec/010answer.solc @@ -1,5 +1,5 @@ contract Answer { - function main() { + public function main() { return 42; } } \ No newline at end of file diff --git a/test/examples/spec/011id.solc b/test/examples/spec/011id.solc index 8c0eb6289..2e79a47e6 100644 --- a/test/examples/spec/011id.solc +++ b/test/examples/spec/011id.solc @@ -2,13 +2,13 @@ contract Id1 { data Bool = False | True; - function id(x) { + public function id(x) { return x ; } - function const(x, y) { return x; } + public function const(x, y) { return x; } - function main() { + public function main() { return const(id(42), Bool.False); } } diff --git a/test/examples/spec/012nid.solc b/test/examples/spec/012nid.solc index 16b629fbd..a27a65659 100644 --- a/test/examples/spec/012nid.solc +++ b/test/examples/spec/012nid.solc @@ -1,15 +1,15 @@ contract Id1 { - function id(x) { + public function id(x) { return x ; } - function nid() { + public function nid() { return id; } - function const(x, y) { return x; } + public function const(x, y) { return x; } - function main() { + public function main() { return const(nid(42), id(1)); } } diff --git a/test/examples/spec/013comp.solc b/test/examples/spec/013comp.solc index 2ce169c2d..a6900271f 100644 --- a/test/examples/spec/013comp.solc +++ b/test/examples/spec/013comp.solc @@ -1,15 +1,15 @@ contract Compose { - function compose(f,g) { + public function compose(f,g) { return lam (x) { return f(g(x)); } ; } - function id(x) { return x; } + public function id(x) { return x; } - function idid() { return compose(id,id); } + public function idid() { return compose(id,id); } - function main() { + public function main() { let f = compose(id,id); return f(42); } diff --git a/test/examples/spec/01id.solc b/test/examples/spec/01id.solc index b858fab16..7e2868436 100644 --- a/test/examples/spec/01id.solc +++ b/test/examples/spec/01id.solc @@ -2,13 +2,13 @@ contract Id1 { data Bool = False | True; - function id(x : word) -> word { + public function id(x : word) -> word { return x ; } - function const(x : word, y : Bool) -> word { return x; } + public function const(x : word, y : Bool) -> word { return x; } - function main() -> word { + public function main() -> word { return const(id(42), Bool.False); } } diff --git a/test/examples/spec/021not.solc b/test/examples/spec/021not.solc index 854e896ec..df5b93773 100644 --- a/test/examples/spec/021not.solc +++ b/test/examples/spec/021not.solc @@ -1,18 +1,18 @@ contract Not { data Bool = False | True; - function main() -> word { + public function main() -> word { return fromBool(bnot(Bool.False)); } - function fromBool(b : Bool) -> word { + public function fromBool(b : Bool) -> word { match(b) { | Bool.False => return 0; | Bool.True => return 1; } } - function bnot(b : Bool) -> Bool { + public function bnot(b : Bool) -> Bool { match b { | Bool.False => return Bool.True; | Bool.True => return Bool.False; diff --git a/test/examples/spec/022add.solc b/test/examples/spec/022add.solc index 2c6fb191e..3ef65f351 100644 --- a/test/examples/spec/022add.solc +++ b/test/examples/spec/022add.solc @@ -7,7 +7,7 @@ function add(x : word, y : word) -> word { } contract Add1 { - function main() -> word { + public function main() -> word { return add(40, 2); } } diff --git a/test/examples/spec/024arith.solc b/test/examples/spec/024arith.solc index d5ace8b98..a79ab49c2 100644 --- a/test/examples/spec/024arith.solc +++ b/test/examples/spec/024arith.solc @@ -58,7 +58,7 @@ function exp(x : word, y: word) -> word { contract Arith { - function main() -> word { + public function main() -> word { return add(mod(sub(div(exp(2,18),4), 1), 16), 27); } } diff --git a/test/examples/spec/027sstore.solc b/test/examples/spec/027sstore.solc index b1006dfc5..cfd5619af 100644 --- a/test/examples/spec/027sstore.solc +++ b/test/examples/spec/027sstore.solc @@ -1,5 +1,5 @@ contract Sstore { - function main() { + public function main() { let res : word; assembly { sstore(0, 42) diff --git a/test/examples/spec/02nid.solc b/test/examples/spec/02nid.solc index 3f5c5cd6f..166d01e2a 100644 --- a/test/examples/spec/02nid.solc +++ b/test/examples/spec/02nid.solc @@ -1,15 +1,15 @@ contract Id1 { - function id(x : word) -> word { + public function id(x : word) -> word { return x ; } - function nid(x : word) -> word { + public function nid(x : word) -> word { return id(x); } - function const(x : word, y : word) -> word { return x; } + public function const(x : word, y : word) -> word { return x; } - function main() -> word { + public function main() -> word { return const(nid(42), id(1)); } } diff --git a/test/examples/spec/031maybe.solc b/test/examples/spec/031maybe.solc index 52347db42..d1de1135f 100644 --- a/test/examples/spec/031maybe.solc +++ b/test/examples/spec/031maybe.solc @@ -1,16 +1,16 @@ contract Option { data Option(a) = None | Some(a); - function just(x : word) -> Option(word) { return Option.Some(x); } + public function just(x : word) -> Option(word) { return Option.Some(x); } - function maybe(n : word, o : Option(word)) -> word { + public function maybe(n : word, o : Option(word)) -> word { match o { | Option.None => return n; | Option.Some(x) => return x; } } - function main() -> word { + public function main() -> word { return maybe(0, Option.Some(42)); } } diff --git a/test/examples/spec/032simplejoin.solc b/test/examples/spec/032simplejoin.solc index 6b0af89e7..074e2100c 100644 --- a/test/examples/spec/032simplejoin.solc +++ b/test/examples/spec/032simplejoin.solc @@ -1,9 +1,9 @@ contract Option { data Option(a) = None | Some(a); - function just(x : word) -> Option(word) { return Option.Some(x); } + public function just(x : word) -> Option(word) { return Option.Some(x); } - function maybe(n : word, o : Option(word)) -> word { + public function maybe(n : word, o : Option(word)) -> word { match o { | Option.None => return n; | Option.Some(x) => return x; @@ -11,7 +11,7 @@ contract Option { } - function join(mmx : Option(Option(word))) -> Option(word) { + public function join(mmx : Option(Option(word))) -> Option(word) { match mmx { | Option.None => return Option.None; | Option.Some(Option.None) => return Option.None; @@ -19,7 +19,7 @@ contract Option { } } - function join2(mmx : Option(Option(word))) -> Option(word) { + public function join2(mmx : Option(Option(word))) -> Option(word) { match mmx { | Option.Some(m) => match m { | Option.None => return Option.None; @@ -29,7 +29,7 @@ contract Option { } } - function main() -> word { + public function main() -> word { return maybe(0, join(Option.Some(Option.Some(42)))); } } diff --git a/test/examples/spec/033join.solc b/test/examples/spec/033join.solc index bfeabef03..d6664528c 100644 --- a/test/examples/spec/033join.solc +++ b/test/examples/spec/033join.solc @@ -1,23 +1,23 @@ contract Option { data Option(a) = None | Some(a); - function just(x : word) -> Option(word) { return Option.Some(x); } + public function just(x : word) -> Option(word) { return Option.Some(x); } - function maybe(n : word, o : Option(word)) -> word { + public function maybe(n : word, o : Option(word)) -> word { match o { | Option.None => return n; | Option.Some(x) => return x; } } - function join(mmx : Option(Option(word))) -> Option(word) { + public function join(mmx : Option(Option(word))) -> Option(word) { match mmx { | Option.Some(Option.Some(x)) => return Option.Some(x); | _ => return Option.None; } } - function main() -> word { + public function main() -> word { return maybe(0, join(Option.Some(Option.Some(42)))); } } diff --git a/test/examples/spec/034cojoin.solc b/test/examples/spec/034cojoin.solc index 46615ebaf..f31954dbc 100644 --- a/test/examples/spec/034cojoin.solc +++ b/test/examples/spec/034cojoin.solc @@ -1,16 +1,16 @@ contract Option { data Option(a) = None | Some(a); - function just(x : word) -> Option(word) { return Option.Some(x); } + public function just(x : word) -> Option(word) { return Option.Some(x); } - function maybe(n : word, o : Option(word)) -> word { + public function maybe(n : word, o : Option(word)) -> word { match o { | Option.None => return n; | Option.Some(x) => return x; } } - function join(mmx : Option(Option(word))) -> Option(word) { + public function join(mmx : Option(Option(word))) -> Option(word) { let result = Option.None; match mmx { | Option.Some(Option.Some(x)) => result = Option.Some(x); @@ -21,21 +21,21 @@ contract Option { return result; } - function extract(mx : Option(word)) -> word { + public function extract(mx : Option(word)) -> word { match mx { | Option.Some(x) => return x; | Option.None => return 0; } } - function cojoin(x : Option(word)) -> Option(Option(word)) { // Test that sum types can grow + public function cojoin(x : Option(word)) -> Option(Option(word)) { // Test that sum types can grow let result = Option.None; result = Option.Some(x); return result; } - function main() -> word { + public function main() -> word { return maybe(0, join(cojoin(Option.Some(42)))); } } diff --git a/test/examples/spec/035padding.solc b/test/examples/spec/035padding.solc index 73a33a79c..c7b687c91 100644 --- a/test/examples/spec/035padding.solc +++ b/test/examples/spec/035padding.solc @@ -1,14 +1,14 @@ contract Option { data Option(a) = None | Some(a); - function maybe(n : word, o : Option(word)) -> word { + public function maybe(n : word, o : Option(word)) -> word { match o { | Option.Some(x) => return x; | Option.None => return n; } } - function main() -> word { + public function main() -> word { return maybe(7, Option.None); } } diff --git a/test/examples/spec/036wildcard.solc b/test/examples/spec/036wildcard.solc index 7c352b156..1e83f44f7 100644 --- a/test/examples/spec/036wildcard.solc +++ b/test/examples/spec/036wildcard.solc @@ -1,14 +1,14 @@ contract Option { data Option(a) = None | Some(a); - function maybe(n : word, o : Option(word)) -> word { + public function maybe(n : word, o : Option(word)) -> word { match o { | Option.Some(x) => return x; | _ => return n; } } - function main() -> word { + public function main() -> word { return maybe(7, Option.None); } } diff --git a/test/examples/spec/037dwarves.solc b/test/examples/spec/037dwarves.solc index db99a2961..94c725297 100644 --- a/test/examples/spec/037dwarves.solc +++ b/test/examples/spec/037dwarves.solc @@ -2,7 +2,7 @@ contract Dwarves { data Dwarf = Doc | Grumpy | Sleepy | Bashful | Happy | Sneezy | Dopey; - function fromEnum(c : Dwarf) -> word { + public function fromEnum(c : Dwarf) -> word { match c { | Dwarf.Doc => return 1; | Dwarf.Grumpy => return 2; @@ -13,5 +13,5 @@ contract Dwarves { } } - function main() -> word { return fromEnum(Dwarf.Happy); } + public function main() -> word { return fromEnum(Dwarf.Happy); } } diff --git a/test/examples/spec/038food0.solc b/test/examples/spec/038food0.solc index 492824486..9d7d33a9a 100644 --- a/test/examples/spec/038food0.solc +++ b/test/examples/spec/038food0.solc @@ -13,11 +13,11 @@ data CFood = Red(Food) | Green(Food) | Nocolor; contract FoodContract { - function id(x : CFood) -> CFood { + public function id(x : CFood) -> CFood { return(x); } - function main() -> word { + public function main() -> word { return fromEnum(id(CFood.Green(Food.Beans))); } } diff --git a/test/examples/spec/039food.solc b/test/examples/spec/039food.solc index 7d8aee99d..ef63da674 100644 --- a/test/examples/spec/039food.solc +++ b/test/examples/spec/039food.solc @@ -15,7 +15,7 @@ data CFood = Red(Food) | Green(Food) | Nocolor; contract FoodContract { - function eat(x : CFood) -> Food { + public function eat(x : CFood) -> Food { match x { | CFood.Red(f) => return f; | CFood.Green(f) => return f; @@ -23,7 +23,7 @@ contract FoodContract { } } - function main() -> word { + public function main() -> word { return fromEnum(eat(CFood.Green(Food.Beans))); } } diff --git a/test/examples/spec/041pair.solc b/test/examples/spec/041pair.solc index 0a72ca3dc..b8180a0a0 100644 --- a/test/examples/spec/041pair.solc +++ b/test/examples/spec/041pair.solc @@ -1,12 +1,12 @@ contract Pair { - function fst(p : (word, word)) -> word { + public function fst(p : (word, word)) -> word { match p { | (a,b) => return a; } } - function main() -> word { + public function main() -> word { return fst((1,0)); } } diff --git a/test/examples/spec/042triple.solc b/test/examples/spec/042triple.solc index ed366e638..10c3724c0 100644 --- a/test/examples/spec/042triple.solc +++ b/test/examples/spec/042triple.solc @@ -1,12 +1,12 @@ contract Triple { - function asel(t : (word, word, word)) -> word { + public function asel(t : (word, word, word)) -> word { match t { | (a,b,c) => return c; } } - function main() -> word { + public function main() -> word { return asel((1,21,42)); } } diff --git a/test/examples/spec/043fstsnd.solc b/test/examples/spec/043fstsnd.solc index a2f6335be..62db7ccf7 100644 --- a/test/examples/spec/043fstsnd.solc +++ b/test/examples/spec/043fstsnd.solc @@ -29,5 +29,5 @@ function addPair(p : Pair(word, word)) -> word { } contract FstSnd { - function main() -> word { return addPair(Pair(41,1)); } + public function main() -> word { return addPair(Pair(41,1)); } } diff --git a/test/examples/spec/047rgb.solc b/test/examples/spec/047rgb.solc index 0f7513f24..576182e56 100644 --- a/test/examples/spec/047rgb.solc +++ b/test/examples/spec/047rgb.solc @@ -1,6 +1,6 @@ contract RGB { data Color = R | G | B; - function main() -> word { + public function main() -> word { match Color.B { | Color.R => return 4; | Color.G => return 2; diff --git a/test/examples/spec/048rgb2.solc b/test/examples/spec/048rgb2.solc index d0a798e53..5e33af5d6 100644 --- a/test/examples/spec/048rgb2.solc +++ b/test/examples/spec/048rgb2.solc @@ -1,7 +1,7 @@ contract RGB { data Color = R | G | B; - function fromEnum(c : Color) -> word { + public function fromEnum(c : Color) -> word { match c { | Color.R => return 4; | Color.G => return 2; @@ -9,5 +9,5 @@ contract RGB { } } - function main() -> word { return fromEnum(Color.B); } + public function main() -> word { return fromEnum(Color.B); } } diff --git a/test/examples/spec/049rgb3.solc b/test/examples/spec/049rgb3.solc index afaa9a217..8cfbaeca4 100644 --- a/test/examples/spec/049rgb3.solc +++ b/test/examples/spec/049rgb3.solc @@ -2,7 +2,7 @@ data RGB = Red(word) | Green(word) | Blue(word); contract RGB3 { - function choose(c:RGB) -> word { + public function choose(c:RGB) -> word { let res : word; match c { | .Red(x) => assembly { res := add(x,1) } @@ -11,7 +11,7 @@ contract RGB3 { } return res; } - function main() -> word { + public function main() -> word { choose(RGB.Green(42)) } } \ No newline at end of file diff --git a/test/examples/spec/051expreturn.solc b/test/examples/spec/051expreturn.solc index 823c2e148..9bbbd0565 100644 --- a/test/examples/spec/051expreturn.solc +++ b/test/examples/spec/051expreturn.solc @@ -50,7 +50,7 @@ forall a b. function unsafeCast(x:a) -> b { contract ExpReturn { - function main() -> Word { + public function main() -> Word { return elimBool1(Bool.False); // return elimBool1(Bool.False); } diff --git a/test/examples/spec/051negBool.solc b/test/examples/spec/051negBool.solc index 696240707..f034aa1b1 100644 --- a/test/examples/spec/051negBool.solc +++ b/test/examples/spec/051negBool.solc @@ -18,12 +18,12 @@ instance B : Neg { contract NegBool { - function fromB(b) { + public function fromB(b) { match b { | B.F => return 0; | B.T => return 1; } } - function main() { return fromB(Neg.neg(B.F)); } + public function main() { return fromB(Neg.neg(B.F)); } } diff --git a/test/examples/spec/052negPair.solc b/test/examples/spec/052negPair.solc index 45a6ce703..f578d8e9a 100644 --- a/test/examples/spec/052negPair.solc +++ b/test/examples/spec/052negPair.solc @@ -45,19 +45,19 @@ instance (a:Neg,b:Neg) => Pair(a,b):Neg { */ contract NegPair { - function bnot(x) { + public function bnot(x) { match x { | B.T => return B.F; | B.F => return B.T; } } - function fromB(b) { + public function fromB(b) { match b { | B.F => return 0; | B.T => return 1; } } - function main() { return fromB(fst(Neg.neg(Pair(B.F,B.T)))); } + public function main() { return fromB(fst(Neg.neg(Pair(B.F,B.T)))); } } diff --git a/test/examples/spec/052return.solc b/test/examples/spec/052return.solc index 90fca519c..e62afc9bf 100644 --- a/test/examples/spec/052return.solc +++ b/test/examples/spec/052return.solc @@ -50,7 +50,7 @@ let res: b; return res; contract ExpReturn { - function main() -> word { + public function main() -> word { return elimBool1(Bool.False); // return elimBool1(Bool.True); } diff --git a/test/examples/spec/053return.solc b/test/examples/spec/053return.solc index 0729e6797..0639c116a 100644 --- a/test/examples/spec/053return.solc +++ b/test/examples/spec/053return.solc @@ -29,7 +29,7 @@ function elimBool1(b:Bool) -> word { contract ExpReturn { - function main() -> word { + public function main() -> word { return elimBool1(Bool.False); // return elimBool1(Bool.True); } diff --git a/test/examples/spec/06comp.solc b/test/examples/spec/06comp.solc index 4d516a258..301615d76 100644 --- a/test/examples/spec/06comp.solc +++ b/test/examples/spec/06comp.solc @@ -1,9 +1,9 @@ contract Compose { - function id(x : word) -> word { return x; } + public function id(x : word) -> word { return x; } - function idid(x : word) -> word { return id(id(x)); } + public function idid(x : word) -> word { return id(id(x)); } - function main() -> word { + public function main() -> word { return idid(42); } } diff --git a/test/examples/spec/09not.solc b/test/examples/spec/09not.solc index 854e896ec..df5b93773 100644 --- a/test/examples/spec/09not.solc +++ b/test/examples/spec/09not.solc @@ -1,18 +1,18 @@ contract Not { data Bool = False | True; - function main() -> word { + public function main() -> word { return fromBool(bnot(Bool.False)); } - function fromBool(b : Bool) -> word { + public function fromBool(b : Bool) -> word { match(b) { | Bool.False => return 0; | Bool.True => return 1; } } - function bnot(b : Bool) -> Bool { + public function bnot(b : Bool) -> Bool { match b { | Bool.False => return Bool.True; | Bool.True => return Bool.False; diff --git a/test/examples/spec/101struct1Field.solc b/test/examples/spec/101struct1Field.solc index c3c6e0712..0f3b36ef2 100644 --- a/test/examples/spec/101struct1Field.solc +++ b/test/examples/spec/101struct1Field.solc @@ -247,7 +247,7 @@ function g() -> word { } contract C { - function main() { + public function main() { f(); return g(); } diff --git a/test/examples/spec/102uintField.solc b/test/examples/spec/102uintField.solc index 7b6f0e7e5..7c908dffd 100644 --- a/test/examples/spec/102uintField.solc +++ b/test/examples/spec/102uintField.solc @@ -254,7 +254,7 @@ function g() -> word { } contract C { - function main() { + public function main() { f(); return g(); } diff --git a/test/examples/spec/103struct3Fields.solc b/test/examples/spec/103struct3Fields.solc index 3ec3f07ab..889616d90 100644 --- a/test/examples/spec/103struct3Fields.solc +++ b/test/examples/spec/103struct3Fields.solc @@ -278,7 +278,7 @@ function g() -> word { } contract C { - function main() { + public function main() { return g(); } } diff --git a/test/examples/spec/105nestedStruct.solc b/test/examples/spec/105nestedStruct.solc index 0d02137eb..455c0a26d 100644 --- a/test/examples/spec/105nestedStruct.solc +++ b/test/examples/spec/105nestedStruct.solc @@ -334,7 +334,7 @@ function readW(w:memory(W)) -> memory(S) { } contract C { - function main() { + public function main() { let s:memory(S) = makeS(); let w:memory(W) = makeW(s); let s2:memory(S) = readW(w); diff --git a/test/examples/spec/10negBool.solc b/test/examples/spec/10negBool.solc index 2a7cec9e8..af8297a97 100644 --- a/test/examples/spec/10negBool.solc +++ b/test/examples/spec/10negBool.solc @@ -18,12 +18,12 @@ instance B : Neg { contract NegBool { - function fromB(b : B) -> word { + public function fromB(b : B) -> word { match b { | B.F => return 0; | B.T => return 1; } } - function main() -> word { return fromB(Neg.neg(B.F)); } + public function main() -> word { return fromB(Neg.neg(B.F)); } } diff --git a/test/examples/spec/111storageStruct.solc b/test/examples/spec/111storageStruct.solc index 693ddcc3e..76a0017db 100644 --- a/test/examples/spec/111storageStruct.solc +++ b/test/examples/spec/111storageStruct.solc @@ -282,7 +282,7 @@ function g() -> word { } contract C { - function main() { + public function main() { return g(); } } diff --git a/test/examples/spec/112ContractStorage.solc b/test/examples/spec/112ContractStorage.solc index 1fc0b773b..f672661a2 100644 --- a/test/examples/spec/112ContractStorage.solc +++ b/test/examples/spec/112ContractStorage.solc @@ -23,7 +23,7 @@ instance StructField(ContractStorage(CounterCxt), counter_sel):CStructField(word contract Counter { // struct CounterCxt { counter:word } - function main() -> word { + public function main() -> word { let cxt : ContractStorage(CounterCxt) = ContractStorage(CounterCxt); let counter_map : MemberAccessProxy(ContractStorage(CounterCxt), counter_sel, ()) = MemberAccessProxy(cxt, counter_sel); diff --git a/test/examples/spec/113counter.solc b/test/examples/spec/113counter.solc index e0ac2d4e3..7fd85e4bc 100644 --- a/test/examples/spec/113counter.solc +++ b/test/examples/spec/113counter.solc @@ -15,7 +15,7 @@ data counter_sel = counter_sel; instance StructField(ContractStorage(()), counter_sel):CStructField(word, ()) {} contract Counter { - function main () -> word { + public function main () -> word { let counter_map /*: MemberAccessProxy(ContractStorage(()), counter_sel, ()) */ = MemberAccessProxy(ContractStorage(()), counter_sel); Assign.assign(LValueMemberAccess.memberAccess(MemberAccessProxy(ContractStorage(()), counter_sel)), add(rval(counter_map), 1)); return rval(counter_map); diff --git a/test/examples/spec/11negPair.solc b/test/examples/spec/11negPair.solc index 7d22a6d68..c18c0272b 100644 --- a/test/examples/spec/11negPair.solc +++ b/test/examples/spec/11negPair.solc @@ -35,19 +35,19 @@ forall a b . a : Neg, b : Neg => instance (a,b):Neg { contract NegPair { - function bnot(x : B) -> B { + public function bnot(x : B) -> B { match x { | B.T => return B.F; | B.F => return B.T; } } - function fromB(b : B) -> word { + public function fromB(b : B) -> word { match b { | B.F => return 0; | B.T => return 1; } } - function main() -> word { return fromB(fst(Neg.neg((B.F,B.T)))); } + public function main() -> word { return fromB(fst(Neg.neg((B.F,B.T)))); } } diff --git a/test/examples/spec/120basicCounter.solc b/test/examples/spec/120basicCounter.solc index bc6c16391..026e1e032 100644 --- a/test/examples/spec/120basicCounter.solc +++ b/test/examples/spec/120basicCounter.solc @@ -2,7 +2,7 @@ import std.{*}; contract Counter { counter : word; - function main() -> word { + public function main() -> word { counter = Num.add(counter, 42); return counter; } diff --git a/test/examples/spec/121counter.solc b/test/examples/spec/121counter.solc index 5940eb6fc..2908b6ef5 100644 --- a/test/examples/spec/121counter.solc +++ b/test/examples/spec/121counter.solc @@ -7,7 +7,7 @@ pragma no-bounded-variable-condition ; contract Counter { counter : word; - function main() -> word { + public function main() -> word { counter = std.addWord(counter, 1); return counter; } diff --git a/test/examples/spec/122counters.solc b/test/examples/spec/122counters.solc index 4dfba68ac..4b13c41db 100644 --- a/test/examples/spec/122counters.solc +++ b/test/examples/spec/122counters.solc @@ -7,7 +7,7 @@ contract Counter { counter1 : word; counter2 : uint256; counter3 : word; - function main() -> word { + public function main() -> word { counter1 += 1; counter3 += 2; return counter1 + counter3; diff --git a/test/examples/spec/123stackAndStorage.solc b/test/examples/spec/123stackAndStorage.solc index 74a26e51c..8da859fac 100644 --- a/test/examples/spec/123stackAndStorage.solc +++ b/test/examples/spec/123stackAndStorage.solc @@ -6,7 +6,7 @@ contract Counter { counter2 : uint256; counter3 : word; - function main() -> word { + public function main() -> word { let x: word; x = counter1 + 1; counter1 = x; diff --git a/test/examples/spec/126nanoerc20.solc b/test/examples/spec/126nanoerc20.solc index 45d02e4fe..865965a7a 100644 --- a/test/examples/spec/126nanoerc20.solc +++ b/test/examples/spec/126nanoerc20.solc @@ -39,13 +39,13 @@ contract Uint { totalSupply : uint256; balances : mapping(address,uint256); - function mint(amount:uint256) -> () { + public function mint(amount:uint256) -> () { balances[owner] = Num.add(balances[owner], amount); totalSupply = Num.add(totalSupply, amount); } // function transferFrom(address src, address dst, uint256 amt) public returns (bool) - function transferFrom(src:address, dst:address, amt:uint256) -> bool { + public function transferFrom(src:address, dst:address, amt:uint256) -> bool { require1(ge(balances[src], amt)); /* @@ -58,21 +58,21 @@ contract Uint { } - function withdraw(src:address, amt:uint256) -> () { + public function withdraw(src:address, amt:uint256) -> () { balances[src] = Num.sub(balances[src], amt):uint256; } - function deposit(dst:address, amt:uint256) -> () { + public function deposit(dst:address, amt:uint256) -> () { balances[dst] = Num.add(balances[dst], amt):uint256; } - function init() -> () { + public function init() -> () { owner = address(0x123456789abcdef); msg_sender = caller(); decimals = uint256(18); } - function main() -> uint256 { + public function main() -> uint256 { init(); mint(uint256(1000)); let src : address = owner; diff --git a/test/examples/spec/127microerc20.solc b/test/examples/spec/127microerc20.solc index d26e01be9..339205819 100644 --- a/test/examples/spec/127microerc20.solc +++ b/test/examples/spec/127microerc20.solc @@ -39,7 +39,7 @@ contract Mini { balances : mapping(address,uint256); allowance : mapping(address, mapping(address, uint256)); - function mint(amount:uint256) -> () { + public function mint(amount:uint256) -> () { balances[owner] = Num.add(balances[owner], amount); totalSupply = Num.add(totalSupply, amount); } @@ -60,7 +60,7 @@ contract Mini { */ // function transferFrom(src:address, dst:address, amt:uint256) -> bool { - function transferFrom(src : address, dst : address, amt : uint256) -> bool { + public function transferFrom(src : address, dst : address, amt : uint256) -> bool { require1(ge(balances[src], amt)); match (Eq.eq(src, msg_sender)) { @@ -90,13 +90,13 @@ contract Mini { */ - function init() -> () { + public function init() -> () { owner = address(0x123456789abcdef); msg_sender = caller(); decimals = uint256(18); } - function main() -> uint256 { + public function main() -> uint256 { init(); mint(uint256(1000)); allowance[owner][msg_sender] = uint256(10000); diff --git a/test/examples/spec/128minierc20.solc b/test/examples/spec/128minierc20.solc index b9d3ebe05..a3c21a15e 100644 --- a/test/examples/spec/128minierc20.solc +++ b/test/examples/spec/128minierc20.solc @@ -28,7 +28,7 @@ contract MiniERC20 { balances : mapping(address,uint256); allowance : mapping(address, mapping(address, uint256)); - function mint(amount:uint256) -> () { + public function mint(amount:uint256) -> () { balances[owner] = Num.add(balances[owner], amount); totalSupply = Num.add(totalSupply, amount); } @@ -48,7 +48,7 @@ contract MiniERC20 { } */ - function transferFrom(src:address, dst:address, amt:uint256) -> bool { + public function transferFrom(src:address, dst:address, amt:uint256) -> bool { let msg_sender = caller(); myrequire( balances[src] >= amt /* "token/insufficient-balance" */ , 0x746f6b656e2f696e73756666696369656e742d62616c616e6365 @@ -73,7 +73,7 @@ contract MiniERC20 { } */ - function approve(usr: address, amt: uint256) -> bool { + public function approve(usr: address, amt: uint256) -> bool { let msg_sender = caller(); allowance[msg_sender][usr] = amt; // emit Approval(msg.sender, usr, amt); @@ -81,12 +81,12 @@ contract MiniERC20 { } - function init() -> () { + public function init() -> () { owner = address(0x123456789abcdef); decimals = uint256(18); // Num.fromWord(18) fails, which may be a problem } - function main() -> uint256 { + public function main() -> uint256 { let msg_sender = caller(); init(); mint(uint256(1000)); diff --git a/test/examples/spec/131constructor.solc b/test/examples/spec/131constructor.solc index 584847e1d..4e0381b90 100644 --- a/test/examples/spec/131constructor.solc +++ b/test/examples/spec/131constructor.solc @@ -2,13 +2,13 @@ contract Counter { - function setCounter(v: word) { + public function setCounter(v: word) { assembly { sstore(0x00, v) } } - function getCounter() -> word { + public function getCounter() -> word { let res; assembly { res := sload(0x00) @@ -21,7 +21,7 @@ contract Counter { setCounter(42); } - function main() -> word { + public function main() -> word { return getCounter(); } } diff --git a/test/examples/spec/135cons3.solc b/test/examples/spec/135cons3.solc index 5a4c0540f..9e808a4c7 100644 --- a/test/examples/spec/135cons3.solc +++ b/test/examples/spec/135cons3.solc @@ -15,7 +15,7 @@ function log1(v:t, topic:word) -> () { contract Counter { // setCounter & getCounter are intentionally low-level to avoid clutter - function setCounter(v: uint256) -> () { + public function setCounter(v: uint256) -> () { match v { | uint256(w) => assembly { sstore(0x00, w) @@ -23,7 +23,7 @@ contract Counter { } } - function getCounter() -> uint256 { + public function getCounter() -> uint256 { let res; assembly { res := sload(0x00) diff --git a/test/examples/spec/903badassign.solc b/test/examples/spec/903badassign.solc index e60723bf8..d3efe69b8 100644 --- a/test/examples/spec/903badassign.solc +++ b/test/examples/spec/903badassign.solc @@ -1,16 +1,16 @@ contract Option { data Option(a) = None | Some(a); - function just(x : word) -> Option(word) { return Option.Some(x); } + public function just(x : word) -> Option(word) { return Option.Some(x); } - function maybe(n : word, o : Option(word)) -> word { + public function maybe(n : word, o : Option(word)) -> word { match o { | Option.None => return n; | Option.Some(x) => return x; } } - function join(mmx : Option(Option(word))) -> Option(word) { + public function join(mmx : Option(Option(word))) -> Option(word) { let result = Option.None; match mmx { | Option.Some(Option.Some(x)) => result = Option.Some(x); @@ -21,7 +21,7 @@ contract Option { return result; } - function main() -> word { + public function main() -> word { return maybe(0, join(Option.Some(Option.Some(42)))); } } diff --git a/test/examples/spec/939badfood.solc b/test/examples/spec/939badfood.solc index 02f14159f..eb81d6b15 100644 --- a/test/examples/spec/939badfood.solc +++ b/test/examples/spec/939badfood.solc @@ -15,7 +15,7 @@ instance Food : Enum { } contract FoodContract { - function main() -> word { + public function main() -> word { return Enum.fromEnum(Food.Beans); } } diff --git a/test/examples/spec/SimpleField.solc b/test/examples/spec/SimpleField.solc index cd7449e1d..3aa1d3e49 100644 --- a/test/examples/spec/SimpleField.solc +++ b/test/examples/spec/SimpleField.solc @@ -6,11 +6,11 @@ pragma no-bounded-variable-condition ; contract Simple { myval : word ; - function getVal () -> word { + public function getVal () -> word { return myval ; } - function main () -> word { + public function main () -> word { return getVal(); } } diff --git a/test/examples/spec/attic/051expreturn.solc b/test/examples/spec/attic/051expreturn.solc index a171f7636..33b372b37 100644 --- a/test/examples/spec/attic/051expreturn.solc +++ b/test/examples/spec/attic/051expreturn.solc @@ -53,7 +53,7 @@ contract ExpReturn { - function main() -> Word { + public function main() -> Word { return elimBool1(Bool.False); // return elimBool1(Bool.False); } diff --git a/test/examples/spec/attic/052return.solc b/test/examples/spec/attic/052return.solc index 723cbdd0a..620987e91 100644 --- a/test/examples/spec/attic/052return.solc +++ b/test/examples/spec/attic/052return.solc @@ -50,7 +50,7 @@ let res: b; return res; contract ExpReturn { - function main() -> word { + public function main() -> word { return elimBool1(Bool.False); // return elimBool1(Bool.True); } diff --git a/test/examples/spec/attic/053return.solc b/test/examples/spec/attic/053return.solc index a30db9e19..29836b50d 100644 --- a/test/examples/spec/attic/053return.solc +++ b/test/examples/spec/attic/053return.solc @@ -29,7 +29,7 @@ function elimBool1(b:Bool) -> word { contract ExpReturn { - function main() -> word { + public function main() -> word { return elimBool1(Bool.False); // return elimBool1(Bool.True); } diff --git a/test/imports/external_lib_main.solc b/test/imports/external_lib_main.solc index e2e152c1b..5ffd122d0 100644 --- a/test/imports/external_lib_main.solc +++ b/test/imports/external_lib_main.solc @@ -3,7 +3,7 @@ import @extlib.math.api; contract External { constructor() {} - function main() -> word { + public function main() -> word { return math.api.sum(39); } }