@@ -64,9 +64,9 @@ import qualified Pact.Types.Runtime as Pact
6464import Pact.Types.Typecheck (AST ,
6565 Fun (FDefun , _fArgs , _fBody , _fInfo ),
6666 Named , Node , TcId (_tiInfo ),
67- TopLevel (TopFun , TopTable ) ,
68- UserType (_utFields , _utName ) ,
69- runTC , tcFailures )
67+ TopLevel (TopFun , TopTable ,
68+ _tlInfo ), UserType (_utFields ,
69+ _utName ), runTC , tcFailures )
7070import qualified Pact.Types.Typecheck as TC
7171
7272import Pact.Analyze.Analyze hiding (invariants )
@@ -649,9 +649,9 @@ verifyFunctionInvariants tables ref = do
649649 else
650650 let parsed = infoToParsed _fInfo
651651 in pure (Left (CheckFailure parsed (TypecheckFailure failures)))
652-
653- -- TODO: should this be an error?
654- _ -> pure $ Right $ TableMap Map. empty
652+ other ->
653+ let parsed = infoToParsed (_tlInfo other)
654+ in pure $ Left ( CheckFailure parsed ( NotAFunction (tShow ref)))
655655
656656-- | Verifies properties on all functions, and that each function maintains all
657657-- invariants.
@@ -679,31 +679,35 @@ verifyModule modules moduleData = do
679679 HM. empty
680680 funRefs
681681
682- case tables of
683- Left errs -> pure (ModuleParseFailures errs)
684- Right tables' -> do
685-
686- let funChecks :: HM. HashMap Text (Ref , Either [ParseFailure ] [(Parsed , Check )])
687- funChecks = moduleFunChecks tables' funTypes
688-
689- funChecks' :: Either [ParseFailure ] (HM. HashMap Text (Ref , [(Parsed , Check )]))
690- funChecks' = sequence (fmap sequence funChecks)
691-
692- verifyFunProps :: (Ref , [(Parsed , Check )]) -> IO [CheckResult ]
693- verifyFunProps = uncurry (verifyFunctionProps tables')
694-
695- case funChecks' of
696- Left errs -> pure (ModuleParseFailures errs)
697- Right funChecks'' -> do
698- funChecks''' <- traverse verifyFunProps funChecks''
699- invariantChecks <- runExceptT $ for funRefs $ \ ref -> do
700- tabledResults <- lift $ verifyFunctionInvariants tables' ref
701- case tabledResults of
702- Left err -> throwError err
703- Right results -> pure results
704- pure $ case invariantChecks of
705- Left err -> ModuleCheckFailure err
706- Right invariantChecks' -> ModuleChecks funChecks''' invariantChecks'
682+ runExceptT' $ do
683+ tables' <- case tables of
684+ Left errs -> throwError (ModuleParseFailures errs)
685+ Right tables' -> pure tables'
686+
687+ let funChecks :: HM. HashMap Text (Ref , Either [ParseFailure ] [(Parsed , Check )])
688+ funChecks = moduleFunChecks tables' funTypes
689+
690+ funChecks' :: Either [ParseFailure ] (HM. HashMap Text (Ref , [(Parsed , Check )]))
691+ funChecks' = sequence (fmap sequence funChecks)
692+
693+ verifyFunProps :: (Ref , [(Parsed , Check )]) -> IO [CheckResult ]
694+ verifyFunProps = uncurry (verifyFunctionProps tables')
695+
696+ funChecks'' <- case funChecks' of
697+ Left errs -> throwError (ModuleParseFailures errs)
698+ Right funChecks'' -> pure funChecks''
699+
700+ funChecks''' <- lift $ traverse verifyFunProps funChecks''
701+ invariantChecks <- for funRefs $ \ ref -> do
702+ tabledResults <- lift $ verifyFunctionInvariants tables' ref
703+ case tabledResults of
704+ Left err -> throwError $ ModuleCheckFailure err
705+ Right results -> pure results
706+
707+ pure $ ModuleChecks funChecks''' invariantChecks
708+
709+ runExceptT' :: Functor m => ExceptT a m a -> m a
710+ runExceptT' = fmap (either id id ) . runExceptT
707711
708712-- | Verifies a one-off 'Check' for a function.
709713verifyCheck
0 commit comments