From 50b313be3f02b59a76fe1102df53456d0f89ad5b Mon Sep 17 00:00:00 2001 From: Bretton Date: Wed, 7 Jun 2023 11:38:19 -0700 Subject: [PATCH 01/35] Name main modules using their file path --- src/Cryptol/ModuleSystem/Base.hs | 5 ++--- src/Cryptol/Parser/ParserUtils.hs | 16 +++++++++++----- src/Cryptol/Utils/Ident.hs | 32 +++++++++++++++++++++++++------ 3 files changed, 39 insertions(+), 14 deletions(-) diff --git a/src/Cryptol/ModuleSystem/Base.hs b/src/Cryptol/ModuleSystem/Base.hs index 63c91bb39..c6eda8f6a 100644 --- a/src/Cryptol/ModuleSystem/Base.hs +++ b/src/Cryptol/ModuleSystem/Base.hs @@ -82,7 +82,7 @@ import qualified Cryptol.Backend.FFI.Error as FFI import Cryptol.Utils.Ident ( preludeName, floatName, arrayName, suiteBName, primeECName , preludeReferenceName, interactiveName, modNameChunks - , modNameToNormalModName, Namespace(NSModule) ) + , modNamesMatch, Namespace(NSModule) ) import Cryptol.Utils.PP (pretty, pp, hang, vcat, ($$), (<+>), (<.>), colon) import Cryptol.Utils.Panic (panic) import Cryptol.Utils.Logger(logPutStrLn, logPrint) @@ -622,8 +622,7 @@ checkModule isrc m = do -- check that the name of the module matches expectations let nm = importedModule isrc - unless (modNameToNormalModName nm == - modNameToNormalModName (thing (P.mName m))) + unless (modNamesMatch nm (thing (P.mName m))) (moduleNameMismatch nm (mName m)) -- remove pattern bindings diff --git a/src/Cryptol/Parser/ParserUtils.hs b/src/Cryptol/Parser/ParserUtils.hs index b5d92f81f..47dda1489 100644 --- a/src/Cryptol/Parser/ParserUtils.hs +++ b/src/Cryptol/Parser/ParserUtils.hs @@ -47,7 +47,7 @@ import Cryptol.Parser.Utils (translateExprToNumT,widthIdent) import Cryptol.Utils.Ident( packModName,packIdent,modNameChunks , identAnonArg, identAnonIfaceMod , modNameArg, modNameIfaceMod - , modNameToText, modNameIsNormal + , modNameToText, mainModName, modNameIsNormal , modNameToNormalModName , unpackIdent, isUpperIdent ) @@ -73,6 +73,8 @@ parse cfg p cs = case unP p cfg eofPos S { sPrevTok = Nothing newtype ParseM a = P { unP :: Config -> Position -> S -> Either ParseError (a,S) } +askConfig :: ParseM Config +askConfig = P \cfg _ s -> Right (cfg, s) lexerP :: (Located Token -> ParseM a) -> ParseM a lexerP k = P $ \cfg p s -> @@ -1203,10 +1205,14 @@ mkIfacePropSyn mbDoc d = -- | Make an unnamed module---gets the name @Main@. mkAnonymousModule :: [TopDecl PName] -> ParseM [Module PName] -mkAnonymousModule = mkTopMods Nothing - . mkModule Located { srcRange = emptyRange - , thing = mkModName [T.pack "Main"] - } +mkAnonymousModule ds = + do src <- cfgSource <$> askConfig + mkTopMods Nothing $ + mkModule Located + { srcRange = emptyRange + , thing = mainModName src + } + ds -- | Make a module which defines a functor instance. mkModuleInstanceAnon :: Located ModName -> diff --git a/src/Cryptol/Utils/Ident.hs b/src/Cryptol/Utils/Ident.hs index c63423348..e0943cbb8 100644 --- a/src/Cryptol/Utils/Ident.hs +++ b/src/Cryptol/Utils/Ident.hs @@ -23,6 +23,7 @@ module Cryptol.Utils.Ident , ModName , modNameToText , textToModName + , mainModName , modNameChunks , modNameChunksText , packModName @@ -40,6 +41,7 @@ module Cryptol.Utils.Ident , modNameArg , modNameIfaceMod , modNameToNormalModName + , modNamesMatch , modNameIsNormal -- * Identifiers @@ -161,6 +163,7 @@ modPathIsNormal p = modNameIsNormal m && all identIsNormal is -------------------------------------------------------------------------------- -- | Top-level Module names are just text. data ModName = ModName Text MaybeAnon + | ModMain FilePath deriving (Eq,Ord,Show,Generic) instance NFData ModName @@ -170,9 +173,10 @@ instance NFData ModName modNameArg :: ModName -> ModName modNameArg (ModName m fl) = case fl of - NormalName -> ModName m AnonModArgName - _ -> panic "modNameArg" ["Name is not normal"] - + NormalName -> ModName m AnonModArgName + AnonModArgName -> panic "modNameArg" ["Name is not normal"] + AnonIfaceModName -> panic "modNameArg" ["Name is not normal"] +modNameArg (ModMain _) = panic "modNameArg" ["Name is not normal"] -- | Change a normal module name to a module name to be used for an -- anonnymous interface. @@ -180,24 +184,38 @@ modNameIfaceMod :: ModName -> ModName modNameIfaceMod (ModName m fl) = case fl of NormalName -> ModName m AnonIfaceModName - _ -> panic "modNameIfaceMod" ["Name is not normal"] + AnonModArgName -> panic "modNameIfaceMod" ["Name is not normal"] + AnonIfaceModName -> panic "modNameIfaceMod" ["Name is not normal"] +modNameIfaceMod (ModMain _) = panic "modNameIfaceMod" ["Name is not normal"] --- | This is used when we check that the name of a module matches the --- file where it is defined. modNameToNormalModName :: ModName -> ModName modNameToNormalModName (ModName t _) = ModName t NormalName +modNameToNormalModName (ModMain _) = + panic "modNameToNormalModName" ["Main module has no normal name"] + +-- | This is used when we check that the name of a module matches the +-- file where it is defined. +modNamesMatch :: ModName -> ModName -> Bool +modNamesMatch (ModName a _) (ModName b _) = a == b +modNamesMatch (ModMain a) (ModMain b) = a == b +modNamesMatch _ _ = False modNameToText :: ModName -> Text modNameToText (ModName x fl) = maybeAnonText fl x +modNameToText (ModMain f) = "Main [" <> T.pack f <> "]" -- | This is useful when we want to hide anonymous modules. modNameIsNormal :: ModName -> Bool modNameIsNormal (ModName _ fl) = isNormal fl +modNameIsNormal (ModMain _) = False -- | Make a normal module name out of text. textToModName :: T.Text -> ModName textToModName txt = ModName txt NormalName +mainModName :: FilePath -> ModName +mainModName = ModMain + -- | Break up a module name on the separators, `Text` version. modNameChunksText :: ModName -> [T.Text] modNameChunksText (ModName x fl) = unfoldr step x @@ -209,6 +227,8 @@ modNameChunksText (ModName x fl) = unfoldr step x (a,b) | T.null b -> Just (maybeAnonText fl str, b) | otherwise -> Just (a,T.drop (T.length modSep) b) +modNameChunksText (ModMain _) = panic "modNameChunksText" + ["Cannot get chunks of main module name"] -- | Break up a module name on the separators, `String` version modNameChunks :: ModName -> [String] From 6c2e2fffcc0335b9de4a8976a09b868c9a16adfd Mon Sep 17 00:00:00 2001 From: Bretton Date: Wed, 7 Jun 2023 14:55:09 -0700 Subject: [PATCH 02/35] Disallow parameterized main modules --- src/Cryptol/Parser/ParserUtils.hs | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/Cryptol/Parser/ParserUtils.hs b/src/Cryptol/Parser/ParserUtils.hs index 47dda1489..50c1e6fed 100644 --- a/src/Cryptol/Parser/ParserUtils.hs +++ b/src/Cryptol/Parser/ParserUtils.hs @@ -14,6 +14,7 @@ {-# LANGUAGE PatternGuards #-} {-# LANGUAGE BlockArguments #-} {-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE LambdaCase #-} -- See Note [-Wincomplete-uni-patterns and irrefutable patterns] in Cryptol.TypeCheck.TypePat {-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-} module Cryptol.Parser.ParserUtils where @@ -31,6 +32,7 @@ import Data.Text(Text) import qualified Data.Text as T import qualified Data.Map as Map import Text.Read(readMaybe) +import Data.Foldable (for_) import GHC.Generics (Generic) import Control.DeepSeq @@ -1206,13 +1208,21 @@ mkIfacePropSyn mbDoc d = -- | Make an unnamed module---gets the name @Main@. mkAnonymousModule :: [TopDecl PName] -> ParseM [Module PName] mkAnonymousModule ds = - do src <- cfgSource <$> askConfig + do for_ ds \case + DParamDecl l _ -> mainParamError l + DModParam p -> mainParamError (srcRange (mpSignature p)) + DInterfaceConstraint _ ps -> mainParamError (srcRange ps) + _ -> pure () + src <- cfgSource <$> askConfig mkTopMods Nothing $ - mkModule Located - { srcRange = emptyRange - , thing = mainModName src - } - ds + mkModule Located + { srcRange = emptyRange + , thing = mainModName src + } + ds + where + mainParamError l = errorMessage l + ["Main module cannot be parameterized"] -- | Make a module which defines a functor instance. mkModuleInstanceAnon :: Located ModName -> From b83bffa9ba1b534a2aa4ca1d9b69a9e9706dcddb Mon Sep 17 00:00:00 2001 From: Bretton Date: Wed, 7 Jun 2023 15:14:49 -0700 Subject: [PATCH 03/35] Slightly modify main module name formatting --- src/Cryptol/Utils/Ident.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Cryptol/Utils/Ident.hs b/src/Cryptol/Utils/Ident.hs index e0943cbb8..d8d41502c 100644 --- a/src/Cryptol/Utils/Ident.hs +++ b/src/Cryptol/Utils/Ident.hs @@ -202,7 +202,7 @@ modNamesMatch _ _ = False modNameToText :: ModName -> Text modNameToText (ModName x fl) = maybeAnonText fl x -modNameToText (ModMain f) = "Main [" <> T.pack f <> "]" +modNameToText (ModMain f) = "Main[" <> T.pack f <> "]" -- | This is useful when we want to hide anonymous modules. modNameIsNormal :: ModName -> Bool From 4a47230b65ec4b0bab3d3399be42fdb3c7733072 Mon Sep 17 00:00:00 2001 From: Bretton Date: Thu, 8 Jun 2023 00:15:20 -0700 Subject: [PATCH 04/35] Tweak unnamed module naming again --- src/Cryptol/Parser/ParserUtils.hs | 2 +- src/Cryptol/Utils/Ident.hs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Cryptol/Parser/ParserUtils.hs b/src/Cryptol/Parser/ParserUtils.hs index 50c1e6fed..c3658fa99 100644 --- a/src/Cryptol/Parser/ParserUtils.hs +++ b/src/Cryptol/Parser/ParserUtils.hs @@ -1222,7 +1222,7 @@ mkAnonymousModule ds = ds where mainParamError l = errorMessage l - ["Main module cannot be parameterized"] + ["Unnamed module cannot be parameterized"] -- | Make a module which defines a functor instance. mkModuleInstanceAnon :: Located ModName -> diff --git a/src/Cryptol/Utils/Ident.hs b/src/Cryptol/Utils/Ident.hs index d8d41502c..08c19ab42 100644 --- a/src/Cryptol/Utils/Ident.hs +++ b/src/Cryptol/Utils/Ident.hs @@ -202,7 +202,7 @@ modNamesMatch _ _ = False modNameToText :: ModName -> Text modNameToText (ModName x fl) = maybeAnonText fl x -modNameToText (ModMain f) = "Main[" <> T.pack f <> "]" +modNameToText (ModMain f) = "[" <> T.pack f <> "]" -- | This is useful when we want to hide anonymous modules. modNameIsNormal :: ModName -> Bool From d581f12746265c96461740b32e1072a7738e804e Mon Sep 17 00:00:00 2001 From: Bretton Date: Thu, 8 Jun 2023 00:15:57 -0700 Subject: [PATCH 05/35] Update tests for Main module name change --- examples/AE.cry | 1 + tests/constraint-guards/constant.icry.stdout | 4 +- tests/constraint-guards/inits.icry.stdout | 2 +- tests/constraint-guards/insert.icry.stdout | 2 +- tests/constraint-guards/len.icry.stdout | 2 +- tests/constraint-guards/mergesort.icry.stdout | 2 +- tests/constraint-guards/nestFun.icry.stdout | 2 +- tests/constraint-guards/nestMod.icry.stdout | 2 +- tests/constraint-guards/noNested.icry.stdout | 2 +- tests/constraint-guards/noPrim.icry.stdout | 2 +- tests/constraint-guards/tail.icry.stdout | 2 +- tests/examples/allexamples.icry.stdout | 46 +++++++++---------- tests/ffi/ffi-header.icry.stdout | 2 +- tests/ffi/ffi-no-dup.icry.stdout | 4 +- tests/ffi/ffi-no-functor.icry.stdout | 4 +- tests/ffi/ffi-reload.icry.stdout | 4 +- tests/ffi/ffi-runtime-errors.icry.stdout | 34 ++++++++------ tests/ffi/ffi-type-errors.icry.stdout | 18 ++++---- tests/ffi/test-ffi.icry.stdout | 2 +- tests/issues/T1440.cry | 2 + tests/issues/T1440.icry.stdout | 10 ++-- tests/issues/T146.icry.stdout | 10 ++-- tests/issues/T1494_1.cry | 1 + tests/issues/T1494_1.icry.stdout | 4 +- tests/issues/issue006.icry.stdout | 2 +- tests/issues/issue058.icry.stdout | 8 ++-- tests/issues/issue081.icry.stdout | 2 +- tests/issues/issue083.icry.stdout | 2 +- tests/issues/issue093.icry.stdout | 2 +- tests/issues/issue1024.icry.stdout | 4 +- tests/issues/issue108.icry.stdout | 8 ++-- tests/issues/issue116.icry.stdout | 2 +- tests/issues/issue1191.icry.stdout | 2 +- tests/issues/issue1210.icry.stdout | 2 +- tests/issues/issue126.icry.stdout | 2 +- tests/issues/issue128.icry.stdout | 2 +- tests/issues/issue130.icry.stdout | 2 +- tests/issues/issue1324.icry.stdout | 4 +- tests/issues/issue133.icry.stdout | 2 +- tests/issues/issue1344.icry.stdout | 2 +- tests/issues/issue138.icry.stdout | 2 +- tests/issues/issue141.icry.stdout | 2 +- tests/issues/issue1441_a.icry.stdout | 2 +- tests/issues/issue1441_b.icry.stdout | 2 +- tests/issues/issue148.icry.stdout | 2 +- tests/issues/issue150.icry.stdout | 2 +- tests/issues/issue1502.icry.stdout | 2 +- tests/issues/issue1503.icry.stdout | 2 +- tests/issues/issue158.icry.stdout | 2 +- tests/issues/issue160.icry.stdout | 2 +- tests/issues/issue171.icry.stdout | 2 +- tests/issues/issue184.icry.stdout | 2 +- tests/issues/issue185.icry.stdout | 2 +- tests/issues/issue198.icry.stdout | 2 +- tests/issues/issue212.icry.stdout | 2 +- tests/issues/issue214.icry.stdout | 2 +- tests/issues/issue268.icry.stdout | 2 +- tests/issues/issue290v2.icry.stdout | 6 +-- tests/issues/issue304.icry.stdout | 2 +- tests/issues/issue308.icry.stdout | 2 +- tests/issues/issue312.icry.stdout | 2 +- tests/issues/issue314.icry.stdout | 2 +- tests/issues/issue323.icry.stdout | 4 +- tests/issues/issue364.icry.stdout | 2 +- tests/issues/issue368.icry.stdout | 2 +- tests/issues/issue389.icry.stdout | 2 +- tests/issues/issue416.icry.stdout | 6 +-- tests/issues/issue494.icry.stdout | 2 +- tests/issues/issue513.icry.stdout | 20 ++++---- tests/issues/issue581.icry.stdout | 2 +- tests/issues/issue582.icry.stdout | 6 +-- tests/issues/issue614.icry.stdout | 2 +- tests/issues/issue640.icry.stdout | 2 +- tests/issues/issue662.icry.stdout | 2 +- tests/issues/issue670.icry.stdout | 2 +- tests/issues/issue68.icry.stdout | 2 +- tests/issues/issue723.icry.stdout | 2 +- tests/issues/issue731.cry | 2 + tests/issues/issue731.icry | 2 +- tests/issues/issue731.icry.stdout | 2 +- tests/issues/issue734.icry.stdout | 2 +- tests/issues/issue78.icry.stdout | 2 +- tests/issues/issue826.icry.stdout | 2 +- tests/issues/issue845.icry.stdout | 4 +- tests/issues/issue850.icry.stdout | 2 +- tests/issues/issue851.icry.stdout | 2 +- tests/issues/issue852.icry.stdout | 2 +- tests/issues/issue877.icry.stdout | 2 +- tests/issues/issue894.icry.stdout | 2 +- tests/issues/issue962.icry.stdout | 4 +- tests/issues/trac133.icry.stdout | 2 +- tests/issues/trac289.icry.stdout | 2 +- tests/modsys/T1330.icry.stdout | 2 +- tests/modsys/functors/T001.icry.stdout | 2 +- tests/modsys/functors/T002.icry.stdout | 2 +- tests/modsys/functors/T003.icry.stdout | 2 +- tests/modsys/functors/T004.icry.stdout | 2 +- tests/modsys/functors/T005.icry.stdout | 2 +- tests/modsys/functors/T006.icry.stdout | 2 +- tests/modsys/functors/T007.icry.stdout | 2 +- tests/modsys/functors/T008.icry.stdout | 2 +- tests/modsys/functors/T009.icry.stdout | 2 +- tests/modsys/functors/T011.icry.stdout | 2 +- tests/modsys/functors/T012.icry.stdout | 2 +- tests/modsys/functors/T013.icry.stdout | 4 +- tests/modsys/functors/T014.icry.stdout | 4 +- tests/modsys/functors/T015.icry.stdout | 2 +- tests/modsys/functors/T016.icry.stdout | 2 +- tests/modsys/functors/T021.icry.stdout | 2 +- tests/modsys/functors/T022.icry.stdout | 2 +- tests/modsys/functors/T025.icry.stdout | 2 +- tests/modsys/functors/T026.icry.stdout | 2 +- tests/modsys/functors/T027.icry.stdout | 2 +- tests/modsys/functors/T028.icry.stdout | 2 +- tests/modsys/functors/T029.icry.stdout | 2 +- tests/modsys/functors/T031.icry.stdout | 2 +- tests/modsys/functors/T033.icry.stdout | 2 +- tests/modsys/functors/T035.icry.stdout | 8 ++-- tests/modsys/functors/T040.icry.stdout | 2 +- tests/modsys/nested/T16.icry.stdout | 2 +- tests/modsys/nested/T7.icry.stdout | 2 +- tests/parser/T437.icry.stdout | 2 +- tests/parser/docs.icry.stdout | 2 +- tests/parser/infix-1.icry.stdout | 2 +- tests/parser/infix-2.icry.stdout | 2 +- tests/parser/infix-3.icry.stdout | 2 +- tests/parser/unary-2.icry.stdout | 2 +- tests/parser/unary.icry.stdout | 2 +- tests/regression/EvenMansour.icry.stdout | 2 +- tests/regression/allsat.icry.stdout | 2 +- tests/regression/bitshift.icry.stdout | 2 +- tests/regression/bvdiv.icry.stdout | 2 +- tests/regression/check01.icry.stdout | 2 +- tests/regression/check02.icry.stdout | 4 +- tests/regression/check03.icry.stdout | 2 +- tests/regression/check04.icry.stdout | 4 +- tests/regression/check05.icry.stdout | 4 +- tests/regression/check06.icry.stdout | 4 +- tests/regression/check07.icry.stdout | 2 +- tests/regression/check08.icry.stdout | 2 +- tests/regression/check09.icry.stdout | 2 +- tests/regression/check10.icry.stdout | 2 +- tests/regression/check11.icry.stdout | 2 +- tests/regression/check12.icry.stdout | 2 +- tests/regression/check13.icry.stdout | 2 +- tests/regression/check14.icry.stdout | 2 +- tests/regression/check15.icry.stdout | 2 +- tests/regression/check16-tab.icry.stdout | 2 +- tests/regression/check16.icry.stdout | 2 +- tests/regression/check17.icry.stdout | 2 +- tests/regression/check18.icry.stdout | 2 +- tests/regression/check19.icry.stdout | 2 +- tests/regression/check20.icry.stdout | 2 +- tests/regression/check21.icry.stdout | 2 +- tests/regression/check22.icry.stdout | 2 +- tests/regression/check23.icry.stdout | 2 +- tests/regression/check24.icry.stdout | 2 +- tests/regression/check26.icry.stdout | 2 +- tests/regression/check27.icry.stdout | 2 +- tests/regression/check28.icry.stdout | 2 +- tests/regression/check29.icry.stdout | 2 +- tests/regression/check30.icry.stdout | 4 +- tests/regression/cplx.icry.stdout | 4 +- tests/regression/dumptests.icry.stdout | 2 +- tests/regression/f2polytest.icry.stdout | 2 +- tests/regression/negshift.icry.stdout | 2 +- tests/regression/poly.icry.stdout | 2 +- tests/regression/primes.icry.stdout | 2 +- tests/regression/r01.icry.stdout | 2 +- tests/regression/r05.icry.stdout | 2 +- .../rational_properties.icry.stdout | 2 +- tests/regression/rec-update.icry.stdout | 2 +- tests/regression/reference.icry.stdout | 2 +- tests/regression/tc-errors.icry.stdout | 20 ++++---- tests/regression/twinmult.icry.stdout | 2 +- tests/regression/word-update.icry.stdout | 2 +- tests/regression/xor-precedence.icry.stdout | 2 +- tests/suiteb/ECDSAKeyPair.icry.stdout | 4 ++ tests/suiteb/ECDSASigGen.icry.stdout | 2 + tests/suiteb/ECDSASigVerify.icry.stdout | 2 + tests/suiteb/aes-mct-ecb.icry.stdout | 2 +- tests/suiteb/aes-vectors.icry.stdout | 2 +- tests/suiteb/sha224-mct.icry.stdout | 2 +- tests/suiteb/sha224-vectors-long.icry.stdout | 2 +- tests/suiteb/sha224-vectors-short.icry.stdout | 2 +- tests/suiteb/sha256-mct.icry.stdout | 2 +- tests/suiteb/sha256-vectors-long.icry.stdout | 2 +- tests/suiteb/sha256-vectors-short.icry.stdout | 2 +- tests/suiteb/sha384-mct.icry.stdout | 2 +- tests/suiteb/sha384-vectors-long.icry.stdout | 2 +- tests/suiteb/sha384-vectors-short.icry.stdout | 2 +- tests/suiteb/sha512-mct.icry.stdout | 2 +- tests/suiteb/sha512-vectors-long.icry.stdout | 2 +- tests/suiteb/sha512-vectors-short.icry.stdout | 2 +- 194 files changed, 308 insertions(+), 290 deletions(-) diff --git a/examples/AE.cry b/examples/AE.cry index 1ac25e774..333e4b051 100644 --- a/examples/AE.cry +++ b/examples/AE.cry @@ -5,6 +5,7 @@ Implementation of the algorithms from the paper "Automated Analysis and Synthesis of Authenticated Encryption Schemes" by Viet Tung Hoang, Jonathan Katz, and Alex J. Malozemoff */ +module AE where parameter type A : * // State type diff --git a/tests/constraint-guards/constant.icry.stdout b/tests/constraint-guards/constant.icry.stdout index 8f64c6d74..d2274d67e 100644 --- a/tests/constraint-guards/constant.icry.stdout +++ b/tests/constraint-guards/constant.icry.stdout @@ -1,12 +1,12 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [constant.cry] [warning] at constant.cry:1:11--1:16 Unused name: n [warning] at constant.cry:14:10--14:15 Unused name: n [warning] at constant.cry:28:1--28:10: - Could not prove that the constraint guards used in defining Main::idTypeNum were exhaustive. + Could not prove that the constraint guards used in defining [constant.cry]::idTypeNum were exhaustive. property isZero_correct Using exhaustive testing. Testing... Passed 1 tests. Q.E.D. diff --git a/tests/constraint-guards/inits.icry.stdout b/tests/constraint-guards/inits.icry.stdout index b5aac7865..12fe88f3a 100644 --- a/tests/constraint-guards/inits.icry.stdout +++ b/tests/constraint-guards/inits.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [inits.cry] Showing a specific instance of polymorphic result: * Using 'Integer' for type of sequence member Using exhaustive testing. diff --git a/tests/constraint-guards/insert.icry.stdout b/tests/constraint-guards/insert.icry.stdout index d80fdf123..5016fbee4 100644 --- a/tests/constraint-guards/insert.icry.stdout +++ b/tests/constraint-guards/insert.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [insert.cry] Using exhaustive testing. Testing... Passed 1 tests. Q.E.D. diff --git a/tests/constraint-guards/len.icry.stdout b/tests/constraint-guards/len.icry.stdout index d80fdf123..30fcf79b4 100644 --- a/tests/constraint-guards/len.icry.stdout +++ b/tests/constraint-guards/len.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [len.cry] Using exhaustive testing. Testing... Passed 1 tests. Q.E.D. diff --git a/tests/constraint-guards/mergesort.icry.stdout b/tests/constraint-guards/mergesort.icry.stdout index b5aac7865..8bf8ce0cb 100644 --- a/tests/constraint-guards/mergesort.icry.stdout +++ b/tests/constraint-guards/mergesort.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [mergesort.cry] Showing a specific instance of polymorphic result: * Using 'Integer' for type of sequence member Using exhaustive testing. diff --git a/tests/constraint-guards/nestFun.icry.stdout b/tests/constraint-guards/nestFun.icry.stdout index 6e8b4478b..20b4d54ab 100644 --- a/tests/constraint-guards/nestFun.icry.stdout +++ b/tests/constraint-guards/nestFun.icry.stdout @@ -1,5 +1,5 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [nestFun.cry] False True diff --git a/tests/constraint-guards/nestMod.icry.stdout b/tests/constraint-guards/nestMod.icry.stdout index 27a449bc0..9cf07049a 100644 --- a/tests/constraint-guards/nestMod.icry.stdout +++ b/tests/constraint-guards/nestMod.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [nestMod.cry] [warning] at nestMod.cry:8:5--8:13: Assuming n to have a numeric type [warning] at nestMod.cry:4:7--4:15: diff --git a/tests/constraint-guards/noNested.icry.stdout b/tests/constraint-guards/noNested.icry.stdout index f9c19b600..0bb6114fb 100644 --- a/tests/constraint-guards/noNested.icry.stdout +++ b/tests/constraint-guards/noNested.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [noNested.cry] At noNested.cry:6:3--6:9: Local declaration `nested` may not use constraint guards. diff --git a/tests/constraint-guards/noPrim.icry.stdout b/tests/constraint-guards/noPrim.icry.stdout index 7fc76db1f..c6d3adcc6 100644 --- a/tests/constraint-guards/noPrim.icry.stdout +++ b/tests/constraint-guards/noPrim.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [noPrim.cry] [error] at noPrim.cry:3:7--3:14: `prime` may not be used in a constraint guard. diff --git a/tests/constraint-guards/tail.icry.stdout b/tests/constraint-guards/tail.icry.stdout index b5aac7865..b6a0812a6 100644 --- a/tests/constraint-guards/tail.icry.stdout +++ b/tests/constraint-guards/tail.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [tail.cry] Showing a specific instance of polymorphic result: * Using 'Integer' for type of sequence member Using exhaustive testing. diff --git a/tests/examples/allexamples.icry.stdout b/tests/examples/allexamples.icry.stdout index c5972d2b7..abe306a29 100644 --- a/tests/examples/allexamples.icry.stdout +++ b/tests/examples/allexamples.icry.stdout @@ -1,7 +1,7 @@ Loading module Cryptol Loading module Cryptol -Loading interface module `parameter` interface of Main -Loading module Main +Loading interface module `parameter` interface of AE +Loading module AE Loading module Cryptol Loading module AES Loading module Cryptol @@ -32,54 +32,54 @@ Loading module Cryptol Loading module Cipher Loading module Test Loading module Cryptol -Loading module Main +Loading module [append.cry] Loading module Cryptol -Loading module Main +Loading module [builtin_lifting.cry] Loading module Cryptol -Loading module Main +Loading module [builtins.cry] Loading module Cryptol -Loading module Main +Loading module [comp.cry] Loading module Cryptol -Loading module Main +Loading module [demote.cry] Loading module Cryptol -Loading module Main +Loading module [inflist.cry] Loading module Cryptol -Loading module Main +Loading module [mini.cry] Loading module Cryptol -Loading module Main +Loading module [props.cry] Loading module Cryptol -Loading module Main +Loading module [split.cry] Loading module Cryptol -Loading module Main +Loading module [splitAt.cry] Loading module Cryptol -Loading module Main +Loading module [width.cry] Loading module Cryptol -Loading module Main +Loading module [xor_cipher.cry] Loading module Cryptol -Loading module Main +Loading module [zero_weird.cry] Loading module Cryptol -Loading module Main +Loading module [contrib/A51.cry] Loading module Cryptol Loading module Cipher Loading module CAST5 Loading module Cryptol -Loading module Main +Loading module [contrib/EvenMansour.cry] Loading module Cryptol Loading module MISTY1 Loading module Cryptol -Loading module Main +Loading module [contrib/RC4.cry] Loading module Cryptol Loading module MKRAND Loading module Cryptol -Loading module Main +Loading module [funstuff/Coins.cry] Loading module Cryptol Loading module FoxChickenCorn Loading module Cryptol -Loading module Main +Loading module [funstuff/NQueens.cry] Loading module Cryptol -Loading module Main +Loading module [funstuff/marble.cry] Loading module Cryptol -Loading module Main +Loading module [maliciousSHA/malicious_SHA1.cry] Loading module Cryptol Loading module AES::GF28 Loading module AES::State @@ -110,7 +110,7 @@ Loading interface module `parameter` interface of AES::ExpandKey Loading module AES::ExpandKey Loading module AES Loading module Common::AES_GCM_SIV -Loading module Main +Loading module [param_modules/AES_GCM_SIV_Test.cry] Loading module Cryptol Loading module AES::GF28 Loading module AES::State diff --git a/tests/ffi/ffi-header.icry.stdout b/tests/ffi/ffi-header.icry.stdout index d3744a160..bf93c0ab9 100644 --- a/tests/ffi/ffi-header.icry.stdout +++ b/tests/ffi/ffi-header.icry.stdout @@ -1,4 +1,4 @@ Loading module Cryptol Loading module Float -Loading module Main +Loading module [test-ffi2.cry] Writing header to test-ffi2.h diff --git a/tests/ffi/ffi-no-dup.icry.stdout b/tests/ffi/ffi-no-dup.icry.stdout index 5cca6738f..7a082ae24 100644 --- a/tests/ffi/ffi-no-dup.icry.stdout +++ b/tests/ffi/ffi-no-dup.icry.stdout @@ -1,8 +1,8 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [ffi-no-dup.cry] -[error] Failed to load foreign implementations for module Main: +[error] Failed to load foreign implementations for module [ffi-no-dup.cry]: Multiple foreign declarations with the same name: `f` defined at ffi-no-dup.cry:6:11--6:12 ffi-no-dup.cry:3:9--3:10 diff --git a/tests/ffi/ffi-no-functor.icry.stdout b/tests/ffi/ffi-no-functor.icry.stdout index 509b2a107..2bb94b138 100644 --- a/tests/ffi/ffi-no-functor.icry.stdout +++ b/tests/ffi/ffi-no-functor.icry.stdout @@ -1,7 +1,7 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [ffi-no-functor.cry] -[error] Failed to load foreign implementations for module Main: +[error] Failed to load foreign implementations for module [ffi-no-functor.cry]: ffi-no-functor.cry:6:11--6:12: Foreign declaration `f` may not appear in a parameterized module. diff --git a/tests/ffi/ffi-reload.icry.stdout b/tests/ffi/ffi-reload.icry.stdout index ed065cd07..b03f3f414 100644 --- a/tests/ffi/ffi-reload.icry.stdout +++ b/tests/ffi/ffi-reload.icry.stdout @@ -1,9 +1,9 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [ffi-reload.cry] Loading dynamic library ffi-reload.so False Loading module Cryptol -Loading module Main +Loading module [ffi-reload.cry] Loading dynamic library ffi-reload.so True diff --git a/tests/ffi/ffi-runtime-errors.icry.stdout b/tests/ffi/ffi-runtime-errors.icry.stdout index 0ee2f7bf3..873da4fa1 100644 --- a/tests/ffi/ffi-runtime-errors.icry.stdout +++ b/tests/ffi/ffi-runtime-errors.icry.stdout @@ -1,25 +1,29 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [ffi-runtime-errors.cry] Loading dynamic library ffi-runtime-errors.so numeric type argument to foreign function is too large: 18446744073709551616 -in type parameter n`892 of function Main::f +in type parameter n`899 of function [ffi-runtime-errors.cry]::f type arguments must fit in a C `size_t` -- Backtrace -- -Main::f called at ffi-runtime-errors.icry:4:1--4:2 +[ffi-runtime-errors.cry]::f called at ffi-runtime-errors.icry:4:1--4:2 -cannot call foreign function Main::g -No foreign implementation is loaded, - or FFI calls are not supported in this context. +cannot call foreign function [ffi-runtime-errors.cry]::g +FFI calls are not supported in this context +If you are trying to evaluate an expression, try rebuilding + Cryptol with FFI support enabled. -cannot call foreign function Main::g -No foreign implementation is loaded, - or FFI calls are not supported in this context. +cannot call foreign function [ffi-runtime-errors.cry]::g +FFI calls are not supported in this context +If you are trying to evaluate an expression, try rebuilding + Cryptol with FFI support enabled. -cannot call foreign function Main::g -No foreign implementation is loaded, - or FFI calls are not supported in this context. -cannot call foreign function Main::g -No foreign implementation is loaded, - or FFI calls are not supported in this context. +cannot call foreign function [ffi-runtime-errors.cry]::g +FFI calls are not supported in this context +If you are trying to evaluate an expression, try rebuilding + Cryptol with FFI support enabled. +cannot call foreign function [ffi-runtime-errors.cry]::g +FFI calls are not supported in this context +If you are trying to evaluate an expression, try rebuilding + Cryptol with FFI support enabled. diff --git a/tests/ffi/ffi-type-errors.icry.stdout b/tests/ffi/ffi-type-errors.icry.stdout index f808f915e..4e43f60bb 100644 --- a/tests/ffi/ffi-type-errors.icry.stdout +++ b/tests/ffi/ffi-type-errors.icry.stdout @@ -1,7 +1,7 @@ Loading module Cryptol Loading module Cryptol Loading module Float -Loading module Main +Loading module [ffi-type-errors.cry] [error] at ffi-type-errors.cry:3:9--3:37: Type unsupported for FFI: @@ -17,7 +17,7 @@ Loading module Main Due to: Unsupported word size Only words of up to 64 bits are supported - When checking the type of 'Main::badWordSizes' + When checking the type of '[ffi-type-errors.cry]::badWordSizes' [error] at ffi-type-errors.cry:4:9--4:44: Type unsupported for FFI: Float 5 11 -> Float 15 113 @@ -32,7 +32,7 @@ Loading module Main Due to: Unsupported Float format Only Float32 and Float64 are supported - When checking the type of 'Main::badFloatSizes' + When checking the type of '[ffi-type-errors.cry]::badFloatSizes' [error] at ffi-type-errors.cry:5:9--6:59: Type unsupported for FFI: [n`962] -> [n`962]([16], [16]) -> [n`962][4][8]{a : [n`962], @@ -56,33 +56,33 @@ Loading module Main Unsupported sequence element type Only words or floats are supported as the element type of (possibly multidimensional) sequences - When checking the type of 'Main::badArrayTypes' + When checking the type of '[ffi-type-errors.cry]::badArrayTypes' [error] at ffi-type-errors.cry:7:9--7:27: Type unsupported for FFI: [32] Due to: FFI binding must be a function - When checking the type of 'Main::notFunction' + When checking the type of '[ffi-type-errors.cry]::notFunction' [error] at ffi-type-errors.cry:8:9--8:32: Kind of type variable unsupported for FFI: t`963 : * Only type variables of kind # are supported - When checking the type of 'Main::badKind' + When checking the type of '[ffi-type-errors.cry]::badKind' [error] at ffi-type-errors.cry:9:9--9:43: Failed to validate user-specified signature. - in the definition of 'Main::noFin', at ffi-type-errors.cry:9:9--9:14, + in the definition of '[ffi-type-errors.cry]::noFin', at ffi-type-errors.cry:9:9--9:14, we need to show that for any type n the following constraints hold: • fin n arising from - declaration of foreign function Main::noFin + declaration of foreign function [ffi-type-errors.cry]::noFin at ffi-type-errors.cry:9:9--9:43 [error] at ffi-type-errors.cry:10:9--10:34: • Unsolvable constraint: fin inf arising from - declaration of foreign function Main::infSeq + declaration of foreign function [ffi-type-errors.cry]::infSeq at ffi-type-errors.cry:10:9--10:34 [error] at ffi-type-errors.cry:11:48--11:49: Wild card types are not allowed in this context diff --git a/tests/ffi/test-ffi.icry.stdout b/tests/ffi/test-ffi.icry.stdout index 920a3bccd..e253f18f8 100644 --- a/tests/ffi/test-ffi.icry.stdout +++ b/tests/ffi/test-ffi.icry.stdout @@ -1,7 +1,7 @@ Loading module Cryptol Loading module Cryptol Loading module Float -Loading module Main +Loading module [test-ffi.cry] Loading dynamic library test-ffi.so 0x03 0x15b4 diff --git a/tests/issues/T1440.cry b/tests/issues/T1440.cry index 089285c1e..86e51e877 100644 --- a/tests/issues/T1440.cry +++ b/tests/issues/T1440.cry @@ -1,3 +1,5 @@ +module T1440 where + import interface submodule X import submodule Y diff --git a/tests/issues/T1440.icry.stdout b/tests/issues/T1440.icry.stdout index 12b4d1ca6..d74531fc9 100644 --- a/tests/issues/T1440.icry.stdout +++ b/tests/issues/T1440.icry.stdout @@ -1,12 +1,12 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module T1440 -[error] at T1440.cry:1:28--1:29 +[error] at T1440.cry:3:28--3:29 Module not in scope: X -[error] at T1440.cry:3:1--3:19 +[error] at T1440.cry:5:1--5:19 Module not in scope: Y -[error] at T1440.cry:14:40--14:42 +[error] at T1440.cry:16:40--16:42 Module not in scope: U1 -[error] at T1440.cry:15:26--15:28 +[error] at T1440.cry:17:26--17:28 Module not in scope: U2 diff --git a/tests/issues/T146.icry.stdout b/tests/issues/T146.icry.stdout index 3b264dba3..6951ba53f 100644 --- a/tests/issues/T146.icry.stdout +++ b/tests/issues/T146.icry.stdout @@ -1,18 +1,18 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [T146.cry] [error] at T146.cry:11:10--11:12: The type ?b is not sufficiently polymorphic. It cannot depend on quantified variables: fv`895 When checking signature variable 'fv' where - ?b is type argument 'fv' of 'Main::ec_v2' at T146.cry:5:19--5:24 - fv`895 is signature variable 'fv' at T146.cry:11:10--11:12 + ?b is type argument 'fv' of '[T146.cry]::ec_v2' at T146.cry:5:19--5:24 + fv`902 is signature variable 'fv' at T146.cry:11:10--11:12 [error] at T146.cry:12:11--12:21: The type ?a is not sufficiently polymorphic. It cannot depend on quantified variables: fv`895 When checking type of field 'v0' where - ?a is type argument 'fv' of 'Main::ec_v1' at T146.cry:4:19--4:24 - fv`895 is signature variable 'fv' at T146.cry:11:10--11:12 + ?a is type argument 'fv' of '[T146.cry]::ec_v1' at T146.cry:4:19--4:24 + fv`902 is signature variable 'fv' at T146.cry:11:10--11:12 diff --git a/tests/issues/T1494_1.cry b/tests/issues/T1494_1.cry index d60028501..621d6014a 100644 --- a/tests/issues/T1494_1.cry +++ b/tests/issues/T1494_1.cry @@ -1,3 +1,4 @@ +module T1494_1 where parameter type n : # diff --git a/tests/issues/T1494_1.icry.stdout b/tests/issues/T1494_1.icry.stdout index f57e993b3..90190df26 100644 --- a/tests/issues/T1494_1.icry.stdout +++ b/tests/issues/T1494_1.icry.stdout @@ -1,4 +1,4 @@ Loading module Cryptol Loading module Cryptol -Loading interface module `parameter` interface of Main -Loading module Main +Loading interface module `parameter` interface of T1494_1 +Loading module T1494_1 diff --git a/tests/issues/issue006.icry.stdout b/tests/issues/issue006.icry.stdout index c7a365c1b..a13a91192 100644 --- a/tests/issues/issue006.icry.stdout +++ b/tests/issues/issue006.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [issue006.cry] 0x00000008 0x00000008 0x00000000 diff --git a/tests/issues/issue058.icry.stdout b/tests/issues/issue058.icry.stdout index cd2df137a..1d532f593 100644 --- a/tests/issues/issue058.icry.stdout +++ b/tests/issues/issue058.icry.stdout @@ -1,10 +1,10 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [issue058.cry] [error] at issue058.cry:4:1--4:16: Failed to validate user-specified signature. - in the definition of 'Main::some', at issue058.cry:4:1--4:5, + in the definition of '[issue058.cry]::some', at issue058.cry:4:1--4:5, we need to show that for any type n the following constraints hold: @@ -14,7 +14,7 @@ Loading module Main at issue058.cry:4:10--4:16 [error] at issue058.cry:7:1--7:17: Failed to validate user-specified signature. - in the definition of 'Main::last', at issue058.cry:7:1--7:5, + in the definition of '[issue058.cry]::last', at issue058.cry:7:1--7:5, we need to show that for any type n, a assuming @@ -26,7 +26,7 @@ Loading module Main at issue058.cry:7:11--7:17 [error] at issue058.cry:10:1--10:17: Failed to validate user-specified signature. - in the definition of 'Main::pad', at issue058.cry:10:1--10:4, + in the definition of '[issue058.cry]::pad', at issue058.cry:10:1--10:4, we need to show that for any type n the following constraints hold: diff --git a/tests/issues/issue081.icry.stdout b/tests/issues/issue081.icry.stdout index 64f2eb8e2..751cde6a6 100644 --- a/tests/issues/issue081.icry.stdout +++ b/tests/issues/issue081.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [issue081.cry] 0x2 0xb 0x2 diff --git a/tests/issues/issue083.icry.stdout b/tests/issues/issue083.icry.stdout index 57a1d7a1c..eb4c7608d 100644 --- a/tests/issues/issue083.icry.stdout +++ b/tests/issues/issue083.icry.stdout @@ -1,3 +1,3 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [issue083.cry] diff --git a/tests/issues/issue093.icry.stdout b/tests/issues/issue093.icry.stdout index 1aef8e83f..f33cb8266 100644 --- a/tests/issues/issue093.icry.stdout +++ b/tests/issues/issue093.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [issue093.cry] property t0 Using exhaustive testing. Testing... Passed 1 tests. Q.E.D. diff --git a/tests/issues/issue1024.icry.stdout b/tests/issues/issue1024.icry.stdout index 491e08fcc..e5b7474bc 100644 --- a/tests/issues/issue1024.icry.stdout +++ b/tests/issues/issue1024.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [issue1024a.cry] [warning] at issue1024a.cry:1:13--1:14 Unused name: f [warning] at issue1024a.cry:2:15--2:16 @@ -28,5 +28,5 @@ Loading module Main where f`895 is signature variable 'f' at issue1024a.cry:4:22--4:32 Loading module Cryptol -Loading module Main +Loading module [issue1024b.cry] 0xffff diff --git a/tests/issues/issue108.icry.stdout b/tests/issues/issue108.icry.stdout index 06998eae0..28e085118 100644 --- a/tests/issues/issue108.icry.stdout +++ b/tests/issues/issue108.icry.stdout @@ -1,13 +1,13 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [issue108.cry] Showing a specific instance of polymorphic result: - * Using '0' for type argument 'b' of 'Main::sum' + * Using '0' for type argument 'b' of '[issue108.cry]::sum' 0x0 Showing a specific instance of polymorphic result: - * Using '2' for type argument 'b' of 'Main::sum' + * Using '2' for type argument 'b' of '[issue108.cry]::sum' 0x2 Showing a specific instance of polymorphic result: - * Using '4' for type argument 'b' of 'Main::sum' + * Using '4' for type argument 'b' of '[issue108.cry]::sum' 0x7 0x37 diff --git a/tests/issues/issue116.icry.stdout b/tests/issues/issue116.icry.stdout index cdd08d402..ff2cd61d3 100644 --- a/tests/issues/issue116.icry.stdout +++ b/tests/issues/issue116.icry.stdout @@ -1,4 +1,4 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [issue116.cry] True diff --git a/tests/issues/issue1191.icry.stdout b/tests/issues/issue1191.icry.stdout index c22d89ac2..3d7033b3d 100644 --- a/tests/issues/issue1191.icry.stdout +++ b/tests/issues/issue1191.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [issue1191.cry] 0xeadbeefd 0xeadbeefd 0xeadbeefd diff --git a/tests/issues/issue1210.icry.stdout b/tests/issues/issue1210.icry.stdout index e49d356ca..beec6a871 100644 --- a/tests/issues/issue1210.icry.stdout +++ b/tests/issues/issue1210.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [issue1210.cry] property mwe Using exhaustive testing. Testing... Passed 16 tests. Q.E.D. diff --git a/tests/issues/issue126.icry.stdout b/tests/issues/issue126.icry.stdout index 57a1d7a1c..ece5f9b17 100644 --- a/tests/issues/issue126.icry.stdout +++ b/tests/issues/issue126.icry.stdout @@ -1,3 +1,3 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [issue126.cry] diff --git a/tests/issues/issue128.icry.stdout b/tests/issues/issue128.icry.stdout index 66dd1b30f..9c9bf09d6 100644 --- a/tests/issues/issue128.icry.stdout +++ b/tests/issues/issue128.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [issue128.cry] Using exhaustive testing. Testing... Passed 1 tests. Q.E.D. diff --git a/tests/issues/issue130.icry.stdout b/tests/issues/issue130.icry.stdout index 4bdbd4b26..a4ce9ab43 100644 --- a/tests/issues/issue130.icry.stdout +++ b/tests/issues/issue130.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [issue130.cry] Using exhaustive testing. Testing... Passed 8 tests. Q.E.D. diff --git a/tests/issues/issue1324.icry.stdout b/tests/issues/issue1324.icry.stdout index a80deb48e..140324ab3 100644 --- a/tests/issues/issue1324.icry.stdout +++ b/tests/issues/issue1324.icry.stdout @@ -1,10 +1,10 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [issue1324.cry] [error] at issue1324.cry:8:1--8:6: Type mismatch: Expected type: 16 Inferred type: 8 Context: {a : [ERROR] _, …} -> _ - When checking the type of 'Main::g' + When checking the type of '[issue1324.cry]::g' diff --git a/tests/issues/issue133.icry.stdout b/tests/issues/issue133.icry.stdout index f47a85504..1a02da4b5 100644 --- a/tests/issues/issue133.icry.stdout +++ b/tests/issues/issue133.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [issue133.cry] Using exhaustive testing. Testing... Passed 256 tests. Q.E.D. diff --git a/tests/issues/issue1344.icry.stdout b/tests/issues/issue1344.icry.stdout index 795267186..3896b09d4 100644 --- a/tests/issues/issue1344.icry.stdout +++ b/tests/issues/issue1344.icry.stdout @@ -1,4 +1,4 @@ Loading module Cryptol Loading module Cryptol Loading module A -Loading module Main +Loading module [issue1344/issue1344.cry] diff --git a/tests/issues/issue138.icry.stdout b/tests/issues/issue138.icry.stdout index 350488419..ca9cd3feb 100644 --- a/tests/issues/issue138.icry.stdout +++ b/tests/issues/issue138.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [issue138.cry] [0xf, 0xe, 0xd, 0xc, 0xb, 0xa, 0x9, 0x8, 0x7, 0x6, 0x5, 0x4, 0x3, 0x2, 0x1, 0x0] [0xf, 0xe, 0xd, 0xc, 0xb, 0xa, 0x9, 0x8, 0x7, 0x6, 0x5, 0x4, 0x3, diff --git a/tests/issues/issue141.icry.stdout b/tests/issues/issue141.icry.stdout index 57a1d7a1c..bb4c8b1cc 100644 --- a/tests/issues/issue141.icry.stdout +++ b/tests/issues/issue141.icry.stdout @@ -1,3 +1,3 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [issue141.cry] diff --git a/tests/issues/issue1441_a.icry.stdout b/tests/issues/issue1441_a.icry.stdout index be86f401d..e527bc0f1 100644 --- a/tests/issues/issue1441_a.icry.stdout +++ b/tests/issues/issue1441_a.icry.stdout @@ -1,4 +1,4 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [issue1441_a.rst] (0x01, 0x02, 0x03, 0x4) diff --git a/tests/issues/issue1441_b.icry.stdout b/tests/issues/issue1441_b.icry.stdout index 3c08df297..7d2bda94e 100644 --- a/tests/issues/issue1441_b.icry.stdout +++ b/tests/issues/issue1441_b.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [issue1441_b.rst] [error] at issue1441_b.rst:28:14--28:18: Type mismatch: diff --git a/tests/issues/issue148.icry.stdout b/tests/issues/issue148.icry.stdout index 7bfc0ec39..7cfe17353 100644 --- a/tests/issues/issue148.icry.stdout +++ b/tests/issues/issue148.icry.stdout @@ -1,4 +1,4 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [issue148.cry] Satisfiable diff --git a/tests/issues/issue150.icry.stdout b/tests/issues/issue150.icry.stdout index e42f8b36e..3b8584c66 100644 --- a/tests/issues/issue150.icry.stdout +++ b/tests/issues/issue150.icry.stdout @@ -1,4 +1,4 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [issue150.cry] maxSeq' : {n, a} (Cmp a, Literal 0 a) => [n]a -> [1 + n]a diff --git a/tests/issues/issue1502.icry.stdout b/tests/issues/issue1502.icry.stdout index 57a1d7a1c..6db799f34 100644 --- a/tests/issues/issue1502.icry.stdout +++ b/tests/issues/issue1502.icry.stdout @@ -1,3 +1,3 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [issue1502.md] diff --git a/tests/issues/issue1503.icry.stdout b/tests/issues/issue1503.icry.stdout index 52cd4132e..eb41abacc 100644 --- a/tests/issues/issue1503.icry.stdout +++ b/tests/issues/issue1503.icry.stdout @@ -1,4 +1,4 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [issue1503.cry] Q.E.D. diff --git a/tests/issues/issue158.icry.stdout b/tests/issues/issue158.icry.stdout index f97a9078b..3cb39d216 100644 --- a/tests/issues/issue158.icry.stdout +++ b/tests/issues/issue158.icry.stdout @@ -1,5 +1,5 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [issue158.cry] Q.E.D. Q.E.D. diff --git a/tests/issues/issue160.icry.stdout b/tests/issues/issue160.icry.stdout index 030a592fd..80e4caa27 100644 --- a/tests/issues/issue160.icry.stdout +++ b/tests/issues/issue160.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [issue160.cry] :prove thm1 Q.E.D. :prove thm2 diff --git a/tests/issues/issue171.icry.stdout b/tests/issues/issue171.icry.stdout index a8db72a5b..589815b3a 100644 --- a/tests/issues/issue171.icry.stdout +++ b/tests/issues/issue171.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [issue171.cry] :prove b Q.E.D. :prove a diff --git a/tests/issues/issue184.icry.stdout b/tests/issues/issue184.icry.stdout index 9a5988ad3..d7636bfb8 100644 --- a/tests/issues/issue184.icry.stdout +++ b/tests/issues/issue184.icry.stdout @@ -1,4 +1,4 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [issue184.cry] [0x01, 0x02, 0x03, 0x04, 0xff, 0x00, 0x01, 0x02, 0x03, 0x04] diff --git a/tests/issues/issue185.icry.stdout b/tests/issues/issue185.icry.stdout index 57a1d7a1c..28506ef8c 100644 --- a/tests/issues/issue185.icry.stdout +++ b/tests/issues/issue185.icry.stdout @@ -1,3 +1,3 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [issue185.cry] diff --git a/tests/issues/issue198.icry.stdout b/tests/issues/issue198.icry.stdout index cdd08d402..1d6a97ee3 100644 --- a/tests/issues/issue198.icry.stdout +++ b/tests/issues/issue198.icry.stdout @@ -1,4 +1,4 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [simon.cry2] True diff --git a/tests/issues/issue212.icry.stdout b/tests/issues/issue212.icry.stdout index 57a1d7a1c..213b65bc0 100644 --- a/tests/issues/issue212.icry.stdout +++ b/tests/issues/issue212.icry.stdout @@ -1,3 +1,3 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [issue212.cry] diff --git a/tests/issues/issue214.icry.stdout b/tests/issues/issue214.icry.stdout index 57a1d7a1c..101180490 100644 --- a/tests/issues/issue214.icry.stdout +++ b/tests/issues/issue214.icry.stdout @@ -1,3 +1,3 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [issue214.cry] diff --git a/tests/issues/issue268.icry.stdout b/tests/issues/issue268.icry.stdout index 038b29cea..0c7ead03e 100644 --- a/tests/issues/issue268.icry.stdout +++ b/tests/issues/issue268.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [issue268.cry] [(0x00, 0x00), (0x00, 0x00), (0x00, 0x00), (0x00, 0x00), (0x00, 0x00), (0x00, 0x00), (0x00, 0x00), (0x00, 0x00), (0x00, 0x00), (0x00, 0x00)] diff --git a/tests/issues/issue290v2.icry.stdout b/tests/issues/issue290v2.icry.stdout index 831325262..ae99c618b 100644 --- a/tests/issues/issue290v2.icry.stdout +++ b/tests/issues/issue290v2.icry.stdout @@ -1,10 +1,10 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [issue290v2.cry] [error] at issue290v2.cry:2:1--2:19: Failed to validate user-specified signature. - in the definition of 'Main::minMax', at issue290v2.cry:2:1--2:7, + in the definition of '[issue290v2.cry]::minMax', at issue290v2.cry:2:1--2:7, we need to show that for any type n, a assuming @@ -19,7 +19,7 @@ Loading module Main Unsolved constraints: • n`892 == 1 arising from - checking a pattern: type of 1st argument of Main::minMax + checking a pattern: type of 1st argument of [issue290v2.cry]::minMax at issue290v2.cry:2:8--2:11 where n`892 is signature variable 'n' at issue290v2.cry:1:11--1:12 diff --git a/tests/issues/issue304.icry.stdout b/tests/issues/issue304.icry.stdout index 872d02a06..9cc740e48 100644 --- a/tests/issues/issue304.icry.stdout +++ b/tests/issues/issue304.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [issue304.cry] x : [64] a : [16] b : [48] diff --git a/tests/issues/issue308.icry.stdout b/tests/issues/issue308.icry.stdout index 57a1d7a1c..c28209600 100644 --- a/tests/issues/issue308.icry.stdout +++ b/tests/issues/issue308.icry.stdout @@ -1,3 +1,3 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [issue308.cry] diff --git a/tests/issues/issue312.icry.stdout b/tests/issues/issue312.icry.stdout index 57a1d7a1c..3058e4954 100644 --- a/tests/issues/issue312.icry.stdout +++ b/tests/issues/issue312.icry.stdout @@ -1,3 +1,3 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [issue312.cry] diff --git a/tests/issues/issue314.icry.stdout b/tests/issues/issue314.icry.stdout index 57a1d7a1c..02465d145 100644 --- a/tests/issues/issue314.icry.stdout +++ b/tests/issues/issue314.icry.stdout @@ -1,3 +1,3 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [issue314.cry] diff --git a/tests/issues/issue323.icry.stdout b/tests/issues/issue323.icry.stdout index 876f909d3..b1bb53848 100644 --- a/tests/issues/issue323.icry.stdout +++ b/tests/issues/issue323.icry.stdout @@ -1,12 +1,12 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [issue323.cry] [error] at issue323.cry:2:1--3:51: Failed to infer the following types: • ?m, type argument 'back' of 'take' at issue323.cry:2:43--2:47 while validating user-specified signature - in the definition of 'Main::testme', at issue323.cry:2:1--2:7, + in the definition of '[issue323.cry]::testme', at issue323.cry:2:1--2:7, we need to show that for any type a the following constraints hold: diff --git a/tests/issues/issue364.icry.stdout b/tests/issues/issue364.icry.stdout index 0943154a1..fd4888476 100644 --- a/tests/issues/issue364.icry.stdout +++ b/tests/issues/issue364.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [issue364.cry] property x_eval Using exhaustive testing. Testing... Passed 1 tests. Q.E.D. diff --git a/tests/issues/issue368.icry.stdout b/tests/issues/issue368.icry.stdout index 57a1d7a1c..169c4c815 100644 --- a/tests/issues/issue368.icry.stdout +++ b/tests/issues/issue368.icry.stdout @@ -1,3 +1,3 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [issue368.cry] diff --git a/tests/issues/issue389.icry.stdout b/tests/issues/issue389.icry.stdout index c5f1087fa..c4bbe4a29 100644 --- a/tests/issues/issue389.icry.stdout +++ b/tests/issues/issue389.icry.stdout @@ -1,5 +1,5 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [issue389.cry] 0x61800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008 0x61800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008 diff --git a/tests/issues/issue416.icry.stdout b/tests/issues/issue416.icry.stdout index 00a6435d9..27ad24f53 100644 --- a/tests/issues/issue416.icry.stdout +++ b/tests/issues/issue416.icry.stdout @@ -1,10 +1,10 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [issue416.cry] [error] at issue416.cry:2:1--2:16: Failed to validate user-specified signature. - in the definition of 'Main::f', at issue416.cry:2:1--2:2, + in the definition of '[issue416.cry]::f', at issue416.cry:2:1--2:2, we need to show that for any type n assuming @@ -17,7 +17,7 @@ Loading module Main at issue416.cry:2:5--2:16 [error] at issue416.cry:5:1--5:16: Failed to validate user-specified signature. - in the definition of 'Main::g', at issue416.cry:5:1--5:2, + in the definition of '[issue416.cry]::g', at issue416.cry:5:1--5:2, we need to show that for any type n assuming diff --git a/tests/issues/issue494.icry.stdout b/tests/issues/issue494.icry.stdout index 72698e616..dcb74809a 100644 --- a/tests/issues/issue494.icry.stdout +++ b/tests/issues/issue494.icry.stdout @@ -1,4 +1,4 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [issue494.cry] gt_words' : {n, m, a} (Cmp a, fin (min (1 + n) (1 + m))) => [n]a -> [m]a -> Bit diff --git a/tests/issues/issue513.icry.stdout b/tests/issues/issue513.icry.stdout index ad1a6057a..ef9364fc3 100644 --- a/tests/issues/issue513.icry.stdout +++ b/tests/issues/issue513.icry.stdout @@ -1,25 +1,25 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [issue513.cry] [warning] at issue513.cry:1:8--1:15: Assuming a to have a numeric type -module Main +module [issue513.cry] /* Recursive */ -Main::test : {a} [1 + a] -Main::test = +[issue513.cry]::test : {a} [1 + a] +[issue513.cry]::test = \{a} -> - Main::$mono + [issue513.cry]::$mono where /* Recursive */ - Main::$mono : [1 + a] - Main::$mono = + [issue513.cry]::$mono : [1 + a] + [issue513.cry]::$mono = (Cryptol::#) 1 a Bit <> [Cryptol::False] [y | i <- Cryptol::zero [a] <> - | y <- Main::$mono] + | y <- [issue513.cry]::$mono] -Main::test +[issue513.cry]::test test : {a} [1 + a] -Main::test 8 +[issue513.cry]::test 8 0x000 diff --git a/tests/issues/issue581.icry.stdout b/tests/issues/issue581.icry.stdout index 57a1d7a1c..3cff9b915 100644 --- a/tests/issues/issue581.icry.stdout +++ b/tests/issues/issue581.icry.stdout @@ -1,3 +1,3 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [issue581.cry] diff --git a/tests/issues/issue582.icry.stdout b/tests/issues/issue582.icry.stdout index 07de82fc5..3bed785c9 100644 --- a/tests/issues/issue582.icry.stdout +++ b/tests/issues/issue582.icry.stdout @@ -30,11 +30,11 @@ Loading module Cryptol use of partial type function (%^) at issue582.icry:6:1--6:16 Loading module Cryptol -Loading module Main +Loading module [issue582.cry] [error] at issue582.cry:2:1--2:11: Failed to validate user-specified signature. - in the definition of 'Main::foo', at issue582.cry:2:1--2:4, + in the definition of '[issue582.cry]::foo', at issue582.cry:2:1--2:4, we need to show that for any type i, j the following constraints hold: @@ -48,7 +48,7 @@ Loading module Main at issue582.cry:1:7--1:21 [error] at issue582.cry:5:1--5:11: Failed to validate user-specified signature. - in the definition of 'Main::bar', at issue582.cry:5:1--5:4, + in the definition of '[issue582.cry]::bar', at issue582.cry:5:1--5:4, we need to show that for any type i, j the following constraints hold: diff --git a/tests/issues/issue614.icry.stdout b/tests/issues/issue614.icry.stdout index 5c55abeca..7459112aa 100644 --- a/tests/issues/issue614.icry.stdout +++ b/tests/issues/issue614.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [issue614.cry] [error] at issue614.cry:1:18--1:20 and issue614.cry:1:31--1:33 The fixities of diff --git a/tests/issues/issue640.icry.stdout b/tests/issues/issue640.icry.stdout index 6b890958c..c5870b46c 100644 --- a/tests/issues/issue640.icry.stdout +++ b/tests/issues/issue640.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [issue640.cry] 0x0 0x0 [0x00, 0x00] diff --git a/tests/issues/issue662.icry.stdout b/tests/issues/issue662.icry.stdout index 3f0641eaa..04669de91 100644 --- a/tests/issues/issue662.icry.stdout +++ b/tests/issues/issue662.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [issue662.cry] property divRoundsDown Using random testing. Testing... Passed 1000 tests. property divEuclidean Using random testing. diff --git a/tests/issues/issue670.icry.stdout b/tests/issues/issue670.icry.stdout index 36ea81ffe..44a8c2b91 100644 --- a/tests/issues/issue670.icry.stdout +++ b/tests/issues/issue670.icry.stdout @@ -1,5 +1,5 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [issue670.cry] g : [6 +++ 2 +++ 1] h : [6 +++ (2 +++ 1)] diff --git a/tests/issues/issue68.icry.stdout b/tests/issues/issue68.icry.stdout index 463f5a0cd..a95d40171 100644 --- a/tests/issues/issue68.icry.stdout +++ b/tests/issues/issue68.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [issue68.cry] Hi! 0x00 Hi! 0x01 Hi! 0x02 diff --git a/tests/issues/issue723.icry.stdout b/tests/issues/issue723.icry.stdout index 86b922758..e0a9ec4fa 100644 --- a/tests/issues/issue723.icry.stdout +++ b/tests/issues/issue723.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [issue723.cry] [error] at issue723.cry:7:5--7:19: Failed to validate user-specified signature. diff --git a/tests/issues/issue731.cry b/tests/issues/issue731.cry index 726a6605b..37d6c3f64 100644 --- a/tests/issues/issue731.cry +++ b/tests/issues/issue731.cry @@ -1,3 +1,5 @@ +module issue731 where + type constraint T n = (fin n, n >= 1) type constraint Both p q = (p, q) diff --git a/tests/issues/issue731.icry b/tests/issues/issue731.icry index 241ac1980..5a2d57d7e 100644 --- a/tests/issues/issue731.icry +++ b/tests/issues/issue731.icry @@ -1,2 +1,2 @@ :l issue731.cry -:browse Main +:browse issue731 diff --git a/tests/issues/issue731.icry.stdout b/tests/issues/issue731.icry.stdout index d97ed83b8..177c7159a 100644 --- a/tests/issues/issue731.icry.stdout +++ b/tests/issues/issue731.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module issue731 Constraint Synonyms =================== diff --git a/tests/issues/issue734.icry.stdout b/tests/issues/issue734.icry.stdout index e47728b24..94bc8bd2c 100644 --- a/tests/issues/issue734.icry.stdout +++ b/tests/issues/issue734.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [issue734.cry] 0x156ad5 0x100 0xff diff --git a/tests/issues/issue78.icry.stdout b/tests/issues/issue78.icry.stdout index bb8d1ac40..f071d46d0 100644 --- a/tests/issues/issue78.icry.stdout +++ b/tests/issues/issue78.icry.stdout @@ -1,4 +1,4 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [issue78.cry] unique : {a, b} (fin a, fin b, a >= 1) => [a][b] -> Bit diff --git a/tests/issues/issue826.icry.stdout b/tests/issues/issue826.icry.stdout index 9623da6b3..a31c760ae 100644 --- a/tests/issues/issue826.icry.stdout +++ b/tests/issues/issue826.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [issue826.cry] [error] at issue826.cry:3:6--3:11: Incorrect type form. diff --git a/tests/issues/issue845.icry.stdout b/tests/issues/issue845.icry.stdout index 4145e2858..fd5eff82a 100644 --- a/tests/issues/issue845.icry.stdout +++ b/tests/issues/issue845.icry.stdout @@ -1,10 +1,10 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [issue845.cry] [error] at issue845.cry:2:1--2:37: Failed to validate user-specified signature. - in the definition of 'Main::rfrac', at issue845.cry:2:1--2:6, + in the definition of '[issue845.cry]::rfrac', at issue845.cry:2:1--2:6, we need to show that for any type m, n the following constraints hold: diff --git a/tests/issues/issue850.icry.stdout b/tests/issues/issue850.icry.stdout index a630df8cc..f3199d0ad 100644 --- a/tests/issues/issue850.icry.stdout +++ b/tests/issues/issue850.icry.stdout @@ -1,4 +1,4 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [issue850.cry] [(ratio 0 1), (ratio 3 1)] diff --git a/tests/issues/issue851.icry.stdout b/tests/issues/issue851.icry.stdout index c4ab0ff1c..c002663c4 100644 --- a/tests/issues/issue851.icry.stdout +++ b/tests/issues/issue851.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [issue851.cry] Using exhaustive testing. Testing... Counterexample problem 0x01 = False diff --git a/tests/issues/issue852.icry.stdout b/tests/issues/issue852.icry.stdout index 57a1d7a1c..99235f3c8 100644 --- a/tests/issues/issue852.icry.stdout +++ b/tests/issues/issue852.icry.stdout @@ -1,3 +1,3 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [issue852.md] diff --git a/tests/issues/issue877.icry.stdout b/tests/issues/issue877.icry.stdout index d534ea752..c5ea77dcf 100644 --- a/tests/issues/issue877.icry.stdout +++ b/tests/issues/issue877.icry.stdout @@ -12,7 +12,7 @@ Showing a specific instance of polymorphic result: * Using 'Bit' for type of sequence member [] Loading module Cryptol -Loading module Main +Loading module [issue877.cry] a : {a} [0]a Showing a specific instance of polymorphic result: * Using 'Integer' for type of sequence member diff --git a/tests/issues/issue894.icry.stdout b/tests/issues/issue894.icry.stdout index 9d8d8cd73..047a6e774 100644 --- a/tests/issues/issue894.icry.stdout +++ b/tests/issues/issue894.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [issue894.cry] [warning] at issue894.cry:1:10--1:11 Unused name: n [warning] at issue894.cry:1:6--1:11: diff --git a/tests/issues/issue962.icry.stdout b/tests/issues/issue962.icry.stdout index b8676f3e7..ca38180db 100644 --- a/tests/issues/issue962.icry.stdout +++ b/tests/issues/issue962.icry.stdout @@ -12,11 +12,11 @@ Parse error at issue962.icry:3:1--3:11 Explicit type applications can only be applied to named values. Unexpected: number`{3} Loading module Cryptol -Loading module Main +Loading module [issue962a.cry] i : {a} (fin a) => [a] -> [a] j : {a} (fin a) => [a]{fld : Integer} -> [a]Integer Loading module Cryptol -Loading module Main +Loading module [issue962b.cry] [error] at issue962b.cry:32:16--32:25: Unexpected bare type application. diff --git a/tests/issues/trac133.icry.stdout b/tests/issues/trac133.icry.stdout index 2a5274351..813f7cbc5 100644 --- a/tests/issues/trac133.icry.stdout +++ b/tests/issues/trac133.icry.stdout @@ -1,5 +1,5 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [trac133.cry] example1 : {a} (a >= 1, 2 >= a) => [16 * a][8] -> [16][8] example2 : {a} (a >= 1, 2 >= a) => [16 * a][8] -> [16][8] diff --git a/tests/issues/trac289.icry.stdout b/tests/issues/trac289.icry.stdout index c491ee9a8..33e3574d4 100644 --- a/tests/issues/trac289.icry.stdout +++ b/tests/issues/trac289.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [trac289.cry] Q.E.D. Counterexample Q.E.D. diff --git a/tests/modsys/T1330.icry.stdout b/tests/modsys/T1330.icry.stdout index 8da6c348b..64542d3b8 100644 --- a/tests/modsys/T1330.icry.stdout +++ b/tests/modsys/T1330.icry.stdout @@ -1,4 +1,4 @@ Loading module Cryptol Loading module Cryptol Loading module modA -Loading module Main +Loading module [T1330/main.cry] diff --git a/tests/modsys/functors/T001.icry.stdout b/tests/modsys/functors/T001.icry.stdout index 9c9423fb4..62cdeec2c 100644 --- a/tests/modsys/functors/T001.icry.stdout +++ b/tests/modsys/functors/T001.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [T001.cry] [error] at T001.cry:16:11--16:12: • Unsolvable constraint: diff --git a/tests/modsys/functors/T002.icry.stdout b/tests/modsys/functors/T002.icry.stdout index aa0e86e34..e8a41cb5d 100644 --- a/tests/modsys/functors/T002.icry.stdout +++ b/tests/modsys/functors/T002.icry.stdout @@ -1,4 +1,4 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [T002.cry] 0x03 diff --git a/tests/modsys/functors/T003.icry.stdout b/tests/modsys/functors/T003.icry.stdout index 3dbf46654..a6a86d3da 100644 --- a/tests/modsys/functors/T003.icry.stdout +++ b/tests/modsys/functors/T003.icry.stdout @@ -1,4 +1,4 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [T003.cry] 0x2b diff --git a/tests/modsys/functors/T004.icry.stdout b/tests/modsys/functors/T004.icry.stdout index 9685a2a14..5128f7a9f 100644 --- a/tests/modsys/functors/T004.icry.stdout +++ b/tests/modsys/functors/T004.icry.stdout @@ -1,4 +1,4 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [T004.cry] 0x06 diff --git a/tests/modsys/functors/T005.icry.stdout b/tests/modsys/functors/T005.icry.stdout index e2fabfbce..35a415325 100644 --- a/tests/modsys/functors/T005.icry.stdout +++ b/tests/modsys/functors/T005.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [T005.cry] [error] at T005.cry:28:11--28:12: • Unsolvable constraint: diff --git a/tests/modsys/functors/T006.icry.stdout b/tests/modsys/functors/T006.icry.stdout index 18a124149..597fba632 100644 --- a/tests/modsys/functors/T006.icry.stdout +++ b/tests/modsys/functors/T006.icry.stdout @@ -1,5 +1,5 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [T006.cry] 0x0f 0x12 diff --git a/tests/modsys/functors/T007.icry.stdout b/tests/modsys/functors/T007.icry.stdout index 43c470464..6f035fa57 100644 --- a/tests/modsys/functors/T007.icry.stdout +++ b/tests/modsys/functors/T007.icry.stdout @@ -1,4 +1,4 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [T007.cry] 0x0d diff --git a/tests/modsys/functors/T008.icry.stdout b/tests/modsys/functors/T008.icry.stdout index 74d3f7bf9..2ea3df745 100644 --- a/tests/modsys/functors/T008.icry.stdout +++ b/tests/modsys/functors/T008.icry.stdout @@ -1,4 +1,4 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [T008.cry] 0x2 diff --git a/tests/modsys/functors/T009.icry.stdout b/tests/modsys/functors/T009.icry.stdout index 8e124ba5f..04dddc577 100644 --- a/tests/modsys/functors/T009.icry.stdout +++ b/tests/modsys/functors/T009.icry.stdout @@ -1,4 +1,4 @@ Loading module Cryptol Loading module Cryptol Loading module T009_S -Loading module Main +Loading module [T009.cry] diff --git a/tests/modsys/functors/T011.icry.stdout b/tests/modsys/functors/T011.icry.stdout index c9603eca1..12960ca8f 100644 --- a/tests/modsys/functors/T011.icry.stdout +++ b/tests/modsys/functors/T011.icry.stdout @@ -1,4 +1,4 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [T011.cry] 0x38 diff --git a/tests/modsys/functors/T012.icry.stdout b/tests/modsys/functors/T012.icry.stdout index 11c5b732c..0989253b2 100644 --- a/tests/modsys/functors/T012.icry.stdout +++ b/tests/modsys/functors/T012.icry.stdout @@ -1,5 +1,5 @@ Loading module Cryptol Loading module Cryptol Loading module T012_M -Loading module Main +Loading module [T012.cry] 0x38 diff --git a/tests/modsys/functors/T013.icry.stdout b/tests/modsys/functors/T013.icry.stdout index bd62e51ec..52762075a 100644 --- a/tests/modsys/functors/T013.icry.stdout +++ b/tests/modsys/functors/T013.icry.stdout @@ -1,7 +1,7 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [T013.cry] [error] at T013.cry:6:30--6:31 • Expected an interface - • `submodule Main::A` is a module + • `submodule [T013.cry]::A` is a module diff --git a/tests/modsys/functors/T014.icry.stdout b/tests/modsys/functors/T014.icry.stdout index 8f6183247..7d44bfda2 100644 --- a/tests/modsys/functors/T014.icry.stdout +++ b/tests/modsys/functors/T014.icry.stdout @@ -1,7 +1,7 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [T014.cry] [error] at T014.cry:5:1--5:19 • Expected a module - • `submodule Main::A` is an interface + • `submodule [T014.cry]::A` is an interface diff --git a/tests/modsys/functors/T015.icry.stdout b/tests/modsys/functors/T015.icry.stdout index 953adc64d..cc4817b1b 100644 --- a/tests/modsys/functors/T015.icry.stdout +++ b/tests/modsys/functors/T015.icry.stdout @@ -1,4 +1,4 @@ Loading module Cryptol Loading module Cryptol Loading interface module T015_S -Loading module Main +Loading module [T015.cry] diff --git a/tests/modsys/functors/T016.icry.stdout b/tests/modsys/functors/T016.icry.stdout index b8bfd491e..335a179c3 100644 --- a/tests/modsys/functors/T016.icry.stdout +++ b/tests/modsys/functors/T016.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [T016.cry] [error] at T016.cry:14:39--14:40: Functor argument does not define value parameter 'x' diff --git a/tests/modsys/functors/T021.icry.stdout b/tests/modsys/functors/T021.icry.stdout index aa0e86e34..80e12f29a 100644 --- a/tests/modsys/functors/T021.icry.stdout +++ b/tests/modsys/functors/T021.icry.stdout @@ -1,4 +1,4 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [T021.cry] 0x03 diff --git a/tests/modsys/functors/T022.icry.stdout b/tests/modsys/functors/T022.icry.stdout index a2244dbbd..bbb2e8380 100644 --- a/tests/modsys/functors/T022.icry.stdout +++ b/tests/modsys/functors/T022.icry.stdout @@ -1,4 +1,4 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [T022.cry] 0x04 diff --git a/tests/modsys/functors/T025.icry.stdout b/tests/modsys/functors/T025.icry.stdout index cd5beea70..3a8444ef3 100644 --- a/tests/modsys/functors/T025.icry.stdout +++ b/tests/modsys/functors/T025.icry.stdout @@ -1,4 +1,4 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [T025.cry] 0x0b diff --git a/tests/modsys/functors/T026.icry.stdout b/tests/modsys/functors/T026.icry.stdout index cd5beea70..b034804d9 100644 --- a/tests/modsys/functors/T026.icry.stdout +++ b/tests/modsys/functors/T026.icry.stdout @@ -1,4 +1,4 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [T026.cry] 0x0b diff --git a/tests/modsys/functors/T027.icry.stdout b/tests/modsys/functors/T027.icry.stdout index 43c470464..3136127cd 100644 --- a/tests/modsys/functors/T027.icry.stdout +++ b/tests/modsys/functors/T027.icry.stdout @@ -1,4 +1,4 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [T027.cry] 0x0d diff --git a/tests/modsys/functors/T028.icry.stdout b/tests/modsys/functors/T028.icry.stdout index cd5beea70..05f7176e8 100644 --- a/tests/modsys/functors/T028.icry.stdout +++ b/tests/modsys/functors/T028.icry.stdout @@ -1,4 +1,4 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [T028.cry] 0x0b diff --git a/tests/modsys/functors/T029.icry.stdout b/tests/modsys/functors/T029.icry.stdout index 76ed2acfb..477f059d1 100644 --- a/tests/modsys/functors/T029.icry.stdout +++ b/tests/modsys/functors/T029.icry.stdout @@ -5,5 +5,5 @@ Loading module Cryptol {a, n} (fin n) => n / 2 == n - n /^ 2 {n, a, b} n == min n n {n} (n >= 1, fin n) => (fin n, n >= 1) -Loading module Main +Loading module [T029.cry] () diff --git a/tests/modsys/functors/T031.icry.stdout b/tests/modsys/functors/T031.icry.stdout index f10397c0e..6a6db9a66 100644 --- a/tests/modsys/functors/T031.icry.stdout +++ b/tests/modsys/functors/T031.icry.stdout @@ -2,5 +2,5 @@ Loading module Cryptol Loading module Cryptol Loading interface module T030_I Loading module T030 -Loading module Main +Loading module [T031.cry] 0x0b diff --git a/tests/modsys/functors/T033.icry.stdout b/tests/modsys/functors/T033.icry.stdout index 57a1d7a1c..9b5e2c72a 100644 --- a/tests/modsys/functors/T033.icry.stdout +++ b/tests/modsys/functors/T033.icry.stdout @@ -1,3 +1,3 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [T033.cry] diff --git a/tests/modsys/functors/T035.icry.stdout b/tests/modsys/functors/T035.icry.stdout index 1c73a1303..8c4921609 100644 --- a/tests/modsys/functors/T035.icry.stdout +++ b/tests/modsys/functors/T035.icry.stdout @@ -1,15 +1,15 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [T035.cry] [warning] at T035.cry:12:5--12:6 This binding for `x` shadows the existing binding at T035.cry:22:1--22:2 [error] at T035.cry:22:11--22:15: Type mismatch: - Expected type: Main::M::X ?m - Inferred type: Main::N::X 0 + Expected type: [T035.cry]::M::X ?m + Inferred type: [T035.cry]::N::X 0 Context: _ -> ERROR When checking function call where - ?m is type argument 'n' of 'Main::M::f' at T035.cry:22:5--22:9 + ?m is type argument 'n' of '[T035.cry]::M::f' at T035.cry:22:5--22:9 diff --git a/tests/modsys/functors/T040.icry.stdout b/tests/modsys/functors/T040.icry.stdout index ce0781a5f..644ded6d4 100644 --- a/tests/modsys/functors/T040.icry.stdout +++ b/tests/modsys/functors/T040.icry.stdout @@ -1,4 +1,4 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [T040.cry] () diff --git a/tests/modsys/nested/T16.icry.stdout b/tests/modsys/nested/T16.icry.stdout index 938fa713c..d6206054a 100644 --- a/tests/modsys/nested/T16.icry.stdout +++ b/tests/modsys/nested/T16.icry.stdout @@ -1,7 +1,7 @@ Loading module Cryptol Loading module Cryptol Loading module T16_M -Loading module Main +Loading module [T16.cry] [error] at T16.cry:2:1--2:19 Module not in scope: A diff --git a/tests/modsys/nested/T7.icry.stdout b/tests/modsys/nested/T7.icry.stdout index 57a1d7a1c..fa7362a41 100644 --- a/tests/modsys/nested/T7.icry.stdout +++ b/tests/modsys/nested/T7.icry.stdout @@ -1,3 +1,3 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [T7.cry] diff --git a/tests/parser/T437.icry.stdout b/tests/parser/T437.icry.stdout index 57a1d7a1c..b9a4170e7 100644 --- a/tests/parser/T437.icry.stdout +++ b/tests/parser/T437.icry.stdout @@ -1,3 +1,3 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [T437.cry] diff --git a/tests/parser/docs.icry.stdout b/tests/parser/docs.icry.stdout index 1c3dd5e63..1ab63f53c 100644 --- a/tests/parser/docs.icry.stdout +++ b/tests/parser/docs.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [docs.cry] test1 : Bit diff --git a/tests/parser/infix-1.icry.stdout b/tests/parser/infix-1.icry.stdout index 5f8376c40..d7a98663c 100644 --- a/tests/parser/infix-1.icry.stdout +++ b/tests/parser/infix-1.icry.stdout @@ -1,4 +1,4 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [infix-1.cry] 0x07 diff --git a/tests/parser/infix-2.icry.stdout b/tests/parser/infix-2.icry.stdout index ebe8dbf07..d487e3271 100644 --- a/tests/parser/infix-2.icry.stdout +++ b/tests/parser/infix-2.icry.stdout @@ -1,5 +1,5 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [infix-2.cry] True True diff --git a/tests/parser/infix-3.icry.stdout b/tests/parser/infix-3.icry.stdout index 976dd8bac..384a65602 100644 --- a/tests/parser/infix-3.icry.stdout +++ b/tests/parser/infix-3.icry.stdout @@ -1,4 +1,4 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [infix-3.cry] (/\) : Bool -> Bool -> Bool diff --git a/tests/parser/unary-2.icry.stdout b/tests/parser/unary-2.icry.stdout index b38d50fc5..9ae38d6be 100644 --- a/tests/parser/unary-2.icry.stdout +++ b/tests/parser/unary-2.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [unary-2.cry] Showing a specific instance of polymorphic result: * Using '[2]' for type argument 'a' of 'Cryptol::min' True diff --git a/tests/parser/unary.icry.stdout b/tests/parser/unary.icry.stdout index ebe8dbf07..597be2466 100644 --- a/tests/parser/unary.icry.stdout +++ b/tests/parser/unary.icry.stdout @@ -1,5 +1,5 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [unary.cry] True True diff --git a/tests/regression/EvenMansour.icry.stdout b/tests/regression/EvenMansour.icry.stdout index 06cd82dc1..34c0c4c0c 100644 --- a/tests/regression/EvenMansour.icry.stdout +++ b/tests/regression/EvenMansour.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [../../examples/contrib/EvenMansour.cry] Using exhaustive testing. Testing... Passed 1 tests. Q.E.D. diff --git a/tests/regression/allsat.icry.stdout b/tests/regression/allsat.icry.stdout index 12c5a4c0a..fb621c2cf 100644 --- a/tests/regression/allsat.icry.stdout +++ b/tests/regression/allsat.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [allsat.cry] Satisfiable Models found: 3375 Satisfiable diff --git a/tests/regression/bitshift.icry.stdout b/tests/regression/bitshift.icry.stdout index 9cc082977..4a0b535d4 100644 --- a/tests/regression/bitshift.icry.stdout +++ b/tests/regression/bitshift.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [bitshift.cry] Using exhaustive testing. Testing... Passed 32 tests. Q.E.D. diff --git a/tests/regression/bvdiv.icry.stdout b/tests/regression/bvdiv.icry.stdout index ae5c6a352..6564083d0 100644 --- a/tests/regression/bvdiv.icry.stdout +++ b/tests/regression/bvdiv.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [bvdiv.cry] property d1 Using exhaustive testing. Testing... Passed 65536 tests. Q.E.D. diff --git a/tests/regression/check01.icry.stdout b/tests/regression/check01.icry.stdout index a1379870f..c436f18a0 100644 --- a/tests/regression/check01.icry.stdout +++ b/tests/regression/check01.icry.stdout @@ -1,5 +1,5 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [check01.cry] [0x00000007, 0x00000014] True diff --git a/tests/regression/check02.icry.stdout b/tests/regression/check02.icry.stdout index a53b2d018..c1cead4aa 100644 --- a/tests/regression/check02.icry.stdout +++ b/tests/regression/check02.icry.stdout @@ -1,7 +1,7 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [check02.cry] Showing a specific instance of polymorphic result: - * Using 'Integer' for 1st type argument of 'Main::ones' + * Using 'Integer' for 1st type argument of '[check02.cry]::ones' [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1] True diff --git a/tests/regression/check03.icry.stdout b/tests/regression/check03.icry.stdout index c980e9393..0901c1300 100644 --- a/tests/regression/check03.icry.stdout +++ b/tests/regression/check03.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [check03.cry] [0x00000000, 0x00000001, 0x00000002, 0x00000003, 0x00000004, 0x00000005, 0x00000006, 0x00000007, 0x00000008, 0x00000009, 0x0000000a] diff --git a/tests/regression/check04.icry.stdout b/tests/regression/check04.icry.stdout index 4b045b572..06de9ac9e 100644 --- a/tests/regression/check04.icry.stdout +++ b/tests/regression/check04.icry.stdout @@ -1,7 +1,7 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [check04.cry] Showing a specific instance of polymorphic result: - * Using 'Integer' for 1st type argument of 'Main::onetwos' + * Using 'Integer' for 1st type argument of '[check04.cry]::onetwos' [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1] True diff --git a/tests/regression/check05.icry.stdout b/tests/regression/check05.icry.stdout index e63615187..d18965ea2 100644 --- a/tests/regression/check05.icry.stdout +++ b/tests/regression/check05.icry.stdout @@ -1,7 +1,7 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [check05.cry] Showing a specific instance of polymorphic result: - * Using 'Integer' for 1st type argument of 'Main::twoones' + * Using 'Integer' for 1st type argument of '[check05.cry]::twoones' [2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2] True diff --git a/tests/regression/check06.icry.stdout b/tests/regression/check06.icry.stdout index 9190ed75d..16bc6ae98 100644 --- a/tests/regression/check06.icry.stdout +++ b/tests/regression/check06.icry.stdout @@ -1,8 +1,8 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [check06.cry] Showing a specific instance of polymorphic result: - * Using 'Integer' for 1st type argument of 'Main::onesytwosy' + * Using 'Integer' for 1st type argument of '[check06.cry]::onesytwosy' [[1, 2], [2, 1], [1, 2], [2, 1], [1, 2], [2, 1], [1, 2], [2, 1], [1, 2], [2, 1], [1, 2]] True diff --git a/tests/regression/check07.icry.stdout b/tests/regression/check07.icry.stdout index 51424538a..79ce158b2 100644 --- a/tests/regression/check07.icry.stdout +++ b/tests/regression/check07.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [check07.cry] [0b00010010001101000101011001111000, 0b00100100011010001010110011110000, 0b01001000110100010101100111100000, diff --git a/tests/regression/check08.icry.stdout b/tests/regression/check08.icry.stdout index c125cd307..54a7150b7 100644 --- a/tests/regression/check08.icry.stdout +++ b/tests/regression/check08.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [check08.cry] [0x00000001, 0x00000002, 0x00000005, 0x0000000c, 0x0000001b] True Q.E.D. diff --git a/tests/regression/check09.icry.stdout b/tests/regression/check09.icry.stdout index 09f1f8ef4..dfd40b24a 100644 --- a/tests/regression/check09.icry.stdout +++ b/tests/regression/check09.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [check09.cry] [warning] at check09.cry:21:5--21:10 This binding for `initS` shadows the existing binding at check09.cry:3:1--3:6 diff --git a/tests/regression/check10.icry.stdout b/tests/regression/check10.icry.stdout index 937d75544..082099987 100644 --- a/tests/regression/check10.icry.stdout +++ b/tests/regression/check10.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [check10.cry] 0x00 0x00 True diff --git a/tests/regression/check11.icry.stdout b/tests/regression/check11.icry.stdout index cdd08d402..9c58588eb 100644 --- a/tests/regression/check11.icry.stdout +++ b/tests/regression/check11.icry.stdout @@ -1,4 +1,4 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [check11.cry] True diff --git a/tests/regression/check12.icry.stdout b/tests/regression/check12.icry.stdout index bea7290e7..a060b0fef 100644 --- a/tests/regression/check12.icry.stdout +++ b/tests/regression/check12.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [check12.cry] [0x00000000, 0x00000001, 0x00000003, 0x00000006, 0x0000000a, 0x0000000f, 0x00000015, 0x0000001c, 0x00000024, 0x0000002d] True diff --git a/tests/regression/check13.icry.stdout b/tests/regression/check13.icry.stdout index 6773e5d93..0e7ba6046 100644 --- a/tests/regression/check13.icry.stdout +++ b/tests/regression/check13.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [check13.cry] 0x96 0x96 True diff --git a/tests/regression/check14.icry.stdout b/tests/regression/check14.icry.stdout index edaacd6ff..fd0096bba 100644 --- a/tests/regression/check14.icry.stdout +++ b/tests/regression/check14.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [check14.cry] Showing a specific instance of polymorphic result: * Using 'Integer' for type of sequence member [[3, 2, 1, 0], [7, 6, 5, 4]] diff --git a/tests/regression/check15.icry.stdout b/tests/regression/check15.icry.stdout index 21dbbdfa1..cb55272b0 100644 --- a/tests/regression/check15.icry.stdout +++ b/tests/regression/check15.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [check15.cry] False 0xabcd True diff --git a/tests/regression/check16-tab.icry.stdout b/tests/regression/check16-tab.icry.stdout index cdd08d402..b12cbb209 100644 --- a/tests/regression/check16-tab.icry.stdout +++ b/tests/regression/check16-tab.icry.stdout @@ -1,4 +1,4 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [check16-tab.cry] True diff --git a/tests/regression/check16.icry.stdout b/tests/regression/check16.icry.stdout index cdd08d402..f319d070c 100644 --- a/tests/regression/check16.icry.stdout +++ b/tests/regression/check16.icry.stdout @@ -1,4 +1,4 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [check16.cry] True diff --git a/tests/regression/check17.icry.stdout b/tests/regression/check17.icry.stdout index cdd08d402..51d1baa1a 100644 --- a/tests/regression/check17.icry.stdout +++ b/tests/regression/check17.icry.stdout @@ -1,4 +1,4 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [check17.cry] True diff --git a/tests/regression/check18.icry.stdout b/tests/regression/check18.icry.stdout index cdd08d402..407543182 100644 --- a/tests/regression/check18.icry.stdout +++ b/tests/regression/check18.icry.stdout @@ -1,4 +1,4 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [check18.cry] True diff --git a/tests/regression/check19.icry.stdout b/tests/regression/check19.icry.stdout index 5ffad4f2e..36ce7698e 100644 --- a/tests/regression/check19.icry.stdout +++ b/tests/regression/check19.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [check19.cry] True True True diff --git a/tests/regression/check20.icry.stdout b/tests/regression/check20.icry.stdout index cdd08d402..e11a97c21 100644 --- a/tests/regression/check20.icry.stdout +++ b/tests/regression/check20.icry.stdout @@ -1,4 +1,4 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [check20.cry] True diff --git a/tests/regression/check21.icry.stdout b/tests/regression/check21.icry.stdout index cdd08d402..7380c9d78 100644 --- a/tests/regression/check21.icry.stdout +++ b/tests/regression/check21.icry.stdout @@ -1,4 +1,4 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [check21.cry] True diff --git a/tests/regression/check22.icry.stdout b/tests/regression/check22.icry.stdout index cdd08d402..e58d4da8a 100644 --- a/tests/regression/check22.icry.stdout +++ b/tests/regression/check22.icry.stdout @@ -1,4 +1,4 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [check22.cry] True diff --git a/tests/regression/check23.icry.stdout b/tests/regression/check23.icry.stdout index cdd08d402..5123f393c 100644 --- a/tests/regression/check23.icry.stdout +++ b/tests/regression/check23.icry.stdout @@ -1,4 +1,4 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [check23.cry] True diff --git a/tests/regression/check24.icry.stdout b/tests/regression/check24.icry.stdout index cdd08d402..6808a6e73 100644 --- a/tests/regression/check24.icry.stdout +++ b/tests/regression/check24.icry.stdout @@ -1,4 +1,4 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [check24.cry] True diff --git a/tests/regression/check26.icry.stdout b/tests/regression/check26.icry.stdout index cdd08d402..d4a9a8742 100644 --- a/tests/regression/check26.icry.stdout +++ b/tests/regression/check26.icry.stdout @@ -1,4 +1,4 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [check26.cry] True diff --git a/tests/regression/check27.icry.stdout b/tests/regression/check27.icry.stdout index cdd08d402..79f4731b1 100644 --- a/tests/regression/check27.icry.stdout +++ b/tests/regression/check27.icry.stdout @@ -1,4 +1,4 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [check27.cry] True diff --git a/tests/regression/check28.icry.stdout b/tests/regression/check28.icry.stdout index cdd08d402..b1e99d33e 100644 --- a/tests/regression/check28.icry.stdout +++ b/tests/regression/check28.icry.stdout @@ -1,4 +1,4 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [check28.cry] True diff --git a/tests/regression/check29.icry.stdout b/tests/regression/check29.icry.stdout index 57a1d7a1c..8121d6de7 100644 --- a/tests/regression/check29.icry.stdout +++ b/tests/regression/check29.icry.stdout @@ -1,3 +1,3 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [check29.cry] diff --git a/tests/regression/check30.icry.stdout b/tests/regression/check30.icry.stdout index 1dedb89b0..4d6e677cb 100644 --- a/tests/regression/check30.icry.stdout +++ b/tests/regression/check30.icry.stdout @@ -1,8 +1,8 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [check30.cry] [warning] at check30.cry:2:13--2:14 This binding for `x` shadows the existing binding at check30.cry:1:1--1:2 Loading module Cryptol -Loading module Main +Loading module [check30.cry] diff --git a/tests/regression/cplx.icry.stdout b/tests/regression/cplx.icry.stdout index e34a6ebdf..e25960370 100644 --- a/tests/regression/cplx.icry.stdout +++ b/tests/regression/cplx.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [cplx.cry] {real = (ratio 420 1), imag = (ratio 0 1)} {real = (ratio 10 1), imag = (ratio 10 1)} {real = (ratio 43 1), imag = (ratio 1 1)} @@ -18,7 +18,7 @@ Testing... Passed 100 tests. :prove cplxMulDistrib Q.E.D. Loading module Cryptol -Loading module Main +Loading module [cplxbroken.cry] property cplxAddAssoc Using random testing. Testing... Passed 100 tests. property cplxMulAssoc Using random testing. diff --git a/tests/regression/dumptests.icry.stdout b/tests/regression/dumptests.icry.stdout index 57a1d7a1c..cf2599f56 100644 --- a/tests/regression/dumptests.icry.stdout +++ b/tests/regression/dumptests.icry.stdout @@ -1,3 +1,3 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [dumptests.cry] diff --git a/tests/regression/f2polytest.icry.stdout b/tests/regression/f2polytest.icry.stdout index 24a4c0be5..fc94c547a 100644 --- a/tests/regression/f2polytest.icry.stdout +++ b/tests/regression/f2polytest.icry.stdout @@ -1,7 +1,7 @@ Loading module Cryptol Loading module Cryptol Loading module Cryptol::Reference -Loading module Main +Loading module [f2polytest.cry] property mult3_9 Using random testing. Testing... Passed 2000 tests. Expected test coverage: 11.49% (1883 of 16384 values) diff --git a/tests/regression/negshift.icry.stdout b/tests/regression/negshift.icry.stdout index 2391954e1..064ac5b67 100644 --- a/tests/regression/negshift.icry.stdout +++ b/tests/regression/negshift.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [negshift.cry] property nls1 Using random testing. Testing... Passed 1000 tests. property nls2 Using random testing. diff --git a/tests/regression/poly.icry.stdout b/tests/regression/poly.icry.stdout index f5455c823..338e1b205 100644 --- a/tests/regression/poly.icry.stdout +++ b/tests/regression/poly.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [poly.cry] {coeffs = [0, 2]} {coeffs = [0, 0, 1]} property polySquare Using random testing. diff --git a/tests/regression/primes.icry.stdout b/tests/regression/primes.icry.stdout index dfaf748d9..b00ccbdd5 100644 --- a/tests/regression/primes.icry.stdout +++ b/tests/regression/primes.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [primes.cry] property recip_correct_17 Using exhaustive testing. Testing... Passed 17 tests. Q.E.D. diff --git a/tests/regression/r01.icry.stdout b/tests/regression/r01.icry.stdout index bb355c4be..2601630d9 100644 --- a/tests/regression/r01.icry.stdout +++ b/tests/regression/r01.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [r01.cry] True False False diff --git a/tests/regression/r05.icry.stdout b/tests/regression/r05.icry.stdout index 57a1d7a1c..9902fd8a9 100644 --- a/tests/regression/r05.icry.stdout +++ b/tests/regression/r05.icry.stdout @@ -1,3 +1,3 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [r05.cry] diff --git a/tests/regression/rational_properties.icry.stdout b/tests/regression/rational_properties.icry.stdout index bfc35cd3d..d026ad738 100644 --- a/tests/regression/rational_properties.icry.stdout +++ b/tests/regression/rational_properties.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [rational_properties.cry] property QaddUnit Using random testing. Testing... Passed 100 tests. property QaddComm Using random testing. diff --git a/tests/regression/rec-update.icry.stdout b/tests/regression/rec-update.icry.stdout index 6da94fc66..351a9d8cb 100644 --- a/tests/regression/rec-update.icry.stdout +++ b/tests/regression/rec-update.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [rec-update.cry] [{x = 0x02, y = True}, {x = 0x03, y = True}, {x = 0x04, y = False}, {x = 0x05, y = False}] [{x = 0x07, y = True}, {x = 0x08, y = True}, diff --git a/tests/regression/reference.icry.stdout b/tests/regression/reference.icry.stdout index 35dfdba3c..a86703d08 100644 --- a/tests/regression/reference.icry.stdout +++ b/tests/regression/reference.icry.stdout @@ -1,7 +1,7 @@ Loading module Cryptol Loading module Cryptol Loading module Cryptol::Reference -Loading module Main +Loading module [reference.cry] property foldl_eq Using random testing. Testing... Passed 1000 tests. property scanl_eq Using random testing. diff --git a/tests/regression/tc-errors.icry.stdout b/tests/regression/tc-errors.icry.stdout index 0eee36930..d7f6a7608 100644 --- a/tests/regression/tc-errors.icry.stdout +++ b/tests/regression/tc-errors.icry.stdout @@ -43,22 +43,22 @@ Parse error at tc-errors.icry:7:1--7:10 Inferred type: Bit When checking user annotation Loading module Cryptol -Loading module Main +Loading module [tc-errors-1.cry] [error] at tc-errors-1.cry:1:9--1:12: Malformed type. Type variables cannot be applied to parameters. Loading module Cryptol -Loading module Main +Loading module [tc-errors-2.cry] -[error] Invalid self dependency: - • type Main::T, defined at 1:6--1:7 +[error] Invalid recursive dependency: + • type [tc-errors-2.cry]::T, defined at 1:6--1:7 Loading module Cryptol -Loading module Main +Loading module [tc-errors-3.cry] [error] at tc-errors-3.cry:2:1--2:6: Failed to validate user-specified signature. - in the definition of 'Main::f', at tc-errors-3.cry:2:1--2:2, + in the definition of '[tc-errors-3.cry]::f', at tc-errors-3.cry:2:1--2:2, we need to show that for any type a the following constraints hold: @@ -71,7 +71,7 @@ Loading module Main use of literal or demoted expression at tc-errors-3.cry:2:5--2:6 Loading module Cryptol -Loading module Main +Loading module [tc-errors-4.cry] [error] at tc-errors-4.cry:1:10--1:11: Wild card types are not allowed in this context @@ -80,18 +80,18 @@ Loading module Main • FFI declarations • declarations with constraint guards Loading module Cryptol -Loading module Main +Loading module [tc-errors-5.cry] [error] at tc-errors-5.cry:2:1--2:7: Inferred type is not sufficiently polymorphic. Quantified variable: a`892 cannot match type: [0]?a - When checking the type of 'Main::f' + When checking the type of '[tc-errors-5.cry]::f' where ?a is type of sequence member at tc-errors-5.cry:2:5--2:7 a`892 is signature variable 'a' at tc-errors-5.cry:1:6--1:7 Loading module Cryptol -Loading module Main +Loading module [tc-errors-6.cry] [error] at tc-errors-6.cry:4:3--4:8: The type ?a is not sufficiently polymorphic. diff --git a/tests/regression/twinmult.icry.stdout b/tests/regression/twinmult.icry.stdout index 2a63a1cd7..9ee5c0e44 100644 --- a/tests/regression/twinmult.icry.stdout +++ b/tests/regression/twinmult.icry.stdout @@ -1,7 +1,7 @@ Loading module Cryptol Loading module Cryptol Loading module PrimeEC -Loading module Main +Loading module [twinmult.cry] property twin_mult_zro Using exhaustive testing. Testing... Passed 49 tests. Q.E.D. diff --git a/tests/regression/word-update.icry.stdout b/tests/regression/word-update.icry.stdout index 3428950a8..fd48ed9b8 100644 --- a/tests/regression/word-update.icry.stdout +++ b/tests/regression/word-update.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [word-update.cry] property wordUpdate Using random testing. Testing... Passed 10000 tests. Expected test coverage: 0.03% (9999 of 2^^25 values) diff --git a/tests/regression/xor-precedence.icry.stdout b/tests/regression/xor-precedence.icry.stdout index 3ba9606f4..224351f99 100644 --- a/tests/regression/xor-precedence.icry.stdout +++ b/tests/regression/xor-precedence.icry.stdout @@ -1,4 +1,4 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module [xor-precedence.cry] False diff --git a/tests/suiteb/ECDSAKeyPair.icry.stdout b/tests/suiteb/ECDSAKeyPair.icry.stdout index 9486087a5..7f0da9a04 100644 --- a/tests/suiteb/ECDSAKeyPair.icry.stdout +++ b/tests/suiteb/ECDSAKeyPair.icry.stdout @@ -2,6 +2,10 @@ Loading module Cryptol Loading module Cryptol Loading module PrimeEC Loading module NISTCurves +Loading module [ECDSAKeyPair.cry] +property p192_keypair_test Using exhaustive testing. +Testing... Passed 1 tests. +Q.E.D. property p192_valid_curve Using exhaustive testing. Testing... Passed 1 tests. Q.E.D. diff --git a/tests/suiteb/ECDSASigGen.icry.stdout b/tests/suiteb/ECDSASigGen.icry.stdout index 64d78e0c1..a535780b4 100644 --- a/tests/suiteb/ECDSASigGen.icry.stdout +++ b/tests/suiteb/ECDSASigGen.icry.stdout @@ -2,6 +2,8 @@ Loading module Cryptol Loading module Cryptol Loading module PrimeEC Loading module NISTCurves +Loading module SuiteB +Loading module [ECDSASigGen.cry] property p192_valid_curve Using exhaustive testing. Testing... Passed 1 tests. Q.E.D. diff --git a/tests/suiteb/ECDSASigVerify.icry.stdout b/tests/suiteb/ECDSASigVerify.icry.stdout index 14ec1ef26..9707f60de 100644 --- a/tests/suiteb/ECDSASigVerify.icry.stdout +++ b/tests/suiteb/ECDSASigVerify.icry.stdout @@ -2,6 +2,8 @@ Loading module Cryptol Loading module Cryptol Loading module PrimeEC Loading module NISTCurves +Loading module SuiteB +Loading module [ECDSASigVerify.cry] property p192_valid_curve Using exhaustive testing. Testing... Passed 1 tests. Q.E.D. diff --git a/tests/suiteb/aes-mct-ecb.icry.stdout b/tests/suiteb/aes-mct-ecb.icry.stdout index 9da27a2be..2f2af5372 100644 --- a/tests/suiteb/aes-mct-ecb.icry.stdout +++ b/tests/suiteb/aes-mct-ecb.icry.stdout @@ -1,7 +1,7 @@ Loading module Cryptol Loading module Cryptol Loading module SuiteB -Loading module Main +Loading module [aes-mct-ecb.cry] property aes128_MCT_vectors_encrypt_correct Using exhaustive testing. Testing... Passed 1 tests. Q.E.D. diff --git a/tests/suiteb/aes-vectors.icry.stdout b/tests/suiteb/aes-vectors.icry.stdout index e29bff4a5..a7b9fb5fb 100644 --- a/tests/suiteb/aes-vectors.icry.stdout +++ b/tests/suiteb/aes-vectors.icry.stdout @@ -1,7 +1,7 @@ Loading module Cryptol Loading module Cryptol Loading module SuiteB -Loading module Main +Loading module [aes-vectors.cry] property aes128_GFSBox_encrypt_correct Using exhaustive testing. Testing... Passed 1 tests. Q.E.D. diff --git a/tests/suiteb/sha224-mct.icry.stdout b/tests/suiteb/sha224-mct.icry.stdout index 3aff82d13..bd34b3bf2 100644 --- a/tests/suiteb/sha224-mct.icry.stdout +++ b/tests/suiteb/sha224-mct.icry.stdout @@ -1,7 +1,7 @@ Loading module Cryptol Loading module Cryptol Loading module SuiteB -Loading module Main +Loading module [sha224-mct.cry] property sha224_mct_correct Using exhaustive testing. Testing... Passed 1 tests. Q.E.D. diff --git a/tests/suiteb/sha224-vectors-long.icry.stdout b/tests/suiteb/sha224-vectors-long.icry.stdout index 1e42c46f6..9f681969e 100644 --- a/tests/suiteb/sha224-vectors-long.icry.stdout +++ b/tests/suiteb/sha224-vectors-long.icry.stdout @@ -1,7 +1,7 @@ Loading module Cryptol Loading module Cryptol Loading module SuiteB -Loading module Main +Loading module [sha224-vectors-long.cry] property sha224_long611 Using exhaustive testing. Testing... Passed 1 tests. Q.E.D. diff --git a/tests/suiteb/sha224-vectors-short.icry.stdout b/tests/suiteb/sha224-vectors-short.icry.stdout index 963e30062..d72485eb5 100644 --- a/tests/suiteb/sha224-vectors-short.icry.stdout +++ b/tests/suiteb/sha224-vectors-short.icry.stdout @@ -1,7 +1,7 @@ Loading module Cryptol Loading module Cryptol Loading module SuiteB -Loading module Main +Loading module [sha224-vectors-short.cry] property sha224_short0 Using exhaustive testing. Testing... Passed 1 tests. Q.E.D. diff --git a/tests/suiteb/sha256-mct.icry.stdout b/tests/suiteb/sha256-mct.icry.stdout index b3ea55376..9d846f5dc 100644 --- a/tests/suiteb/sha256-mct.icry.stdout +++ b/tests/suiteb/sha256-mct.icry.stdout @@ -1,7 +1,7 @@ Loading module Cryptol Loading module Cryptol Loading module SuiteB -Loading module Main +Loading module [sha256-mct.cry] property sha256_mct_correct Using exhaustive testing. Testing... Passed 1 tests. Q.E.D. diff --git a/tests/suiteb/sha256-vectors-long.icry.stdout b/tests/suiteb/sha256-vectors-long.icry.stdout index 47379f397..be9abb46c 100644 --- a/tests/suiteb/sha256-vectors-long.icry.stdout +++ b/tests/suiteb/sha256-vectors-long.icry.stdout @@ -1,7 +1,7 @@ Loading module Cryptol Loading module Cryptol Loading module SuiteB -Loading module Main +Loading module [sha256-vectors-long.cry] property sha256_long611 Using exhaustive testing. Testing... Passed 1 tests. Q.E.D. diff --git a/tests/suiteb/sha256-vectors-short.icry.stdout b/tests/suiteb/sha256-vectors-short.icry.stdout index 892a8d7cd..6ae2819b7 100644 --- a/tests/suiteb/sha256-vectors-short.icry.stdout +++ b/tests/suiteb/sha256-vectors-short.icry.stdout @@ -1,7 +1,7 @@ Loading module Cryptol Loading module Cryptol Loading module SuiteB -Loading module Main +Loading module [sha256-vectors-short.cry] property sha256_short0 Using exhaustive testing. Testing... Passed 1 tests. Q.E.D. diff --git a/tests/suiteb/sha384-mct.icry.stdout b/tests/suiteb/sha384-mct.icry.stdout index cab1d26c8..938f85d45 100644 --- a/tests/suiteb/sha384-mct.icry.stdout +++ b/tests/suiteb/sha384-mct.icry.stdout @@ -1,7 +1,7 @@ Loading module Cryptol Loading module Cryptol Loading module SuiteB -Loading module Main +Loading module [sha384-mct.cry] property sha384_mct_correct Using exhaustive testing. Testing... Passed 1 tests. Q.E.D. diff --git a/tests/suiteb/sha384-vectors-long.icry.stdout b/tests/suiteb/sha384-vectors-long.icry.stdout index 7fe5c6b64..374293ac3 100644 --- a/tests/suiteb/sha384-vectors-long.icry.stdout +++ b/tests/suiteb/sha384-vectors-long.icry.stdout @@ -1,7 +1,7 @@ Loading module Cryptol Loading module Cryptol Loading module SuiteB -Loading module Main +Loading module [sha384-vectors-long.cry] property sha384_long1123 Using exhaustive testing. Testing... Passed 1 tests. Q.E.D. diff --git a/tests/suiteb/sha384-vectors-short.icry.stdout b/tests/suiteb/sha384-vectors-short.icry.stdout index f985f31ba..2251e62e1 100644 --- a/tests/suiteb/sha384-vectors-short.icry.stdout +++ b/tests/suiteb/sha384-vectors-short.icry.stdout @@ -1,7 +1,7 @@ Loading module Cryptol Loading module Cryptol Loading module SuiteB -Loading module Main +Loading module [sha384-vectors-short.cry] property sha384_short0 Using exhaustive testing. Testing... Passed 1 tests. Q.E.D. diff --git a/tests/suiteb/sha512-mct.icry.stdout b/tests/suiteb/sha512-mct.icry.stdout index ebe14c2b3..77f87fbfe 100644 --- a/tests/suiteb/sha512-mct.icry.stdout +++ b/tests/suiteb/sha512-mct.icry.stdout @@ -1,7 +1,7 @@ Loading module Cryptol Loading module Cryptol Loading module SuiteB -Loading module Main +Loading module [sha512-mct.cry] property sha512_mct_correct Using exhaustive testing. Testing... Passed 1 tests. Q.E.D. diff --git a/tests/suiteb/sha512-vectors-long.icry.stdout b/tests/suiteb/sha512-vectors-long.icry.stdout index 24e131ec9..a420567bf 100644 --- a/tests/suiteb/sha512-vectors-long.icry.stdout +++ b/tests/suiteb/sha512-vectors-long.icry.stdout @@ -1,7 +1,7 @@ Loading module Cryptol Loading module Cryptol Loading module SuiteB -Loading module Main +Loading module [sha512-vectors-long.cry] property sha512_long1123 Using exhaustive testing. Testing... Passed 1 tests. Q.E.D. diff --git a/tests/suiteb/sha512-vectors-short.icry.stdout b/tests/suiteb/sha512-vectors-short.icry.stdout index 0bc35a96e..3bfa0d338 100644 --- a/tests/suiteb/sha512-vectors-short.icry.stdout +++ b/tests/suiteb/sha512-vectors-short.icry.stdout @@ -1,7 +1,7 @@ Loading module Cryptol Loading module Cryptol Loading module SuiteB -Loading module Main +Loading module [sha512-vectors-short.cry] property sha512_short0 Using exhaustive testing. Testing... Passed 1 tests. Q.E.D. From 0b118774bebcb2d873039e0f1a1ead2ed1291f33 Mon Sep 17 00:00:00 2001 From: Bretton Date: Wed, 14 Jun 2023 17:23:41 -0700 Subject: [PATCH 06/35] Implement project config file, loading all modules --- cryptol-repl-internal/REPL/Haskeline.hs | 23 +++-- cryptol.cabal | 8 +- cryptol/Main.hs | 78 +++++++++++----- src/Cryptol/Project.hs | 113 ++++++++++++++++++++++++ src/Cryptol/REPL/Command.hs | 25 ++---- src/Cryptol/REPL/Monad.hs | 16 ++++ 6 files changed, 217 insertions(+), 46 deletions(-) create mode 100644 src/Cryptol/Project.hs diff --git a/cryptol-repl-internal/REPL/Haskeline.hs b/cryptol-repl-internal/REPL/Haskeline.hs index 4d0bdc797..b05ae7b51 100644 --- a/cryptol-repl-internal/REPL/Haskeline.hs +++ b/cryptol-repl-internal/REPL/Haskeline.hs @@ -14,6 +14,7 @@ module REPL.Haskeline where +import qualified Cryptol.Project as Project import Cryptol.REPL.Command import Cryptol.REPL.Monad import Cryptol.REPL.Trie @@ -131,21 +132,29 @@ loadCryRC cryrc = else return status -- | Haskeline-specific repl implementation. -repl :: Cryptolrc -> ReplMode -> Bool -> Bool -> REPL () -> IO CommandResult -repl cryrc replMode callStacks stopOnError begin = +repl :: Cryptolrc -> Maybe Project.Config -> ReplMode -> Bool -> Bool -> REPL () -> IO CommandResult +repl cryrc projectConfig replMode callStacks stopOnError begin = runREPL isBatch callStacks stdoutLogger replAction where -- this flag is used to suppress the logo and prompts - isBatch = case replMode of - InteractiveRepl -> False - Batch _ -> True - InteractiveBatch _ -> True + isBatch = + case projectConfig of + Just _ -> True + Nothing -> + case replMode of + InteractiveRepl -> False + Batch _ -> True + InteractiveBatch _ -> True replAction = do status <- loadCryRC cryrc if crSuccess status - then begin >> crySession replMode stopOnError + then do + begin + case projectConfig of + Just config -> Project.run config + Nothing -> crySession replMode stopOnError else return status -- | Try to set the history file. diff --git a/cryptol.cabal b/cryptol.cabal index f7a6b69e1..a1db7f15a 100644 --- a/cryptol.cabal +++ b/cryptol.cabal @@ -46,6 +46,7 @@ library Default-language: Haskell2010 Build-depends: base >= 4.9 && < 5, + aeson, arithmoi >= 0.12, async >= 2.2 && < 2.3, base-compat >= 0.6 && < 0.13, @@ -85,7 +86,8 @@ library mtl >= 2.2.1, time >= 1.6.0.1, panic >= 0.3, - what4 >= 1.4 && < 1.7 + what4 >= 1.4 && < 1.7, + yaml >= 0.11.11 && < 0.12 if impl(ghc >= 9.0) build-depends: ghc-bignum >= 1.0 && < 1.4 @@ -238,7 +240,9 @@ library Cryptol.REPL.Help, Cryptol.REPL.Browse, Cryptol.REPL.Monad, - Cryptol.REPL.Trie + Cryptol.REPL.Trie, + + Cryptol.Project Other-modules: Cryptol.Parser.LexerUtils, Cryptol.Parser.ParserUtils, diff --git a/cryptol/Main.hs b/cryptol/Main.hs index 85beccf28..9f4e8d867 100644 --- a/cryptol/Main.hs +++ b/cryptol/Main.hs @@ -8,6 +8,7 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} +{-# LANGUAGE LambdaCase #-} {-# LANGUAGE OverloadedStrings #-} module Main where @@ -18,6 +19,7 @@ import Cryptol.REPL.Monad (REPL,updateREPLTitle,setUpdateREPLTitle, io,prependSearchPath,setSearchPath,parseSearchPath) import qualified Cryptol.REPL.Monad as REPL import Cryptol.ModuleSystem.Env(ModulePath(..)) +import qualified Cryptol.Project as Project import REPL.Haskeline import REPL.Logo @@ -26,6 +28,7 @@ import Cryptol.Utils.PP import Cryptol.Version (displayVersion) import Control.Monad (when, void) +import Data.Maybe (isJust, isNothing) import GHC.IO.Encoding (setLocaleEncoding, utf8) import System.Console.GetOpt (OptDescr(..),ArgOrder(..),ArgDescr(..),getOpt,usageInfo) @@ -47,6 +50,7 @@ data Options = Options , optVersion :: Bool , optHelp :: Bool , optBatch :: ReplMode + , optProject :: Maybe FilePath , optCallStacks :: Bool , optCommands :: [String] , optColorMode :: ColorMode @@ -62,6 +66,7 @@ defaultOptions = Options , optVersion = False , optHelp = False , optBatch = InteractiveRepl + , optProject = Nothing , optCallStacks = True , optCommands = [] , optColorMode = AutoColor @@ -79,6 +84,10 @@ options = , Option "" ["interactive-batch"] (ReqArg setInteractiveBatchScript "FILE") "run the script provided and exit, but behave as if running an interactive session" + , Option "p" ["project"] (ReqArg setProject "CRYPROJECT") + ("Load and verify a Cryptol project using the provided project " + ++ "configuration file or directory containing 'cryproject.yaml'") + , Option "e" ["stop-on-error"] (NoArg setStopOnError) "stop script execution as soon as an error occurs." @@ -137,6 +146,9 @@ setBatchScript path = modify $ \ opts -> opts { optBatch = Batch path } setInteractiveBatchScript :: String -> OptParser Options setInteractiveBatchScript path = modify $ \ opts -> opts { optBatch = InteractiveBatch path } +setProject :: String -> OptParser Options +setProject path = modify $ \opts -> opts { optProject = Just path } + -- | Set the color mode of the terminal output. setColorMode :: String -> OptParser Options setColorMode "auto" = modify $ \ opts -> opts { optColorMode = AutoColor } @@ -225,11 +237,13 @@ main = do | optVersion opts -> displayVersion putStrLn | otherwise -> do (opts', mCleanup) <- setupCmdScript opts - status <- repl (optCryptolrc opts') - (optBatch opts') - (optCallStacks opts') - (optStopOnError opts') - (setupREPL opts') + (opts'', mConfig) <- setupProject opts' + status <- repl (optCryptolrc opts'') + mConfig + (optBatch opts'') + (optCallStacks opts'') + (optStopOnError opts'') + (setupREPL opts'') case mCleanup of Nothing -> return () Just cmdFile -> removeFile cmdFile @@ -249,7 +263,27 @@ setupCmdScript opts = hClose h when (optBatch opts /= InteractiveRepl) $ putStrLn "[warning] --command argument specified; ignoring batch file" - return (opts { optBatch = InteractiveBatch path }, Just path) + when (isJust (optProject opts)) $ + putStrLn $ + "[warning] --command argument specified; " + ++ "ignoring project configuration file" + return + ( opts { optBatch = InteractiveBatch path, optProject = Nothing } + , Just path ) + +setupProject :: Options -> IO (Options, Maybe Project.Config) +setupProject opts = + case optProject opts of + Nothing -> pure (opts, Nothing) + Just path -> do + when (optBatch opts /= InteractiveRepl) $ + putStrLn "[warning] --project argument specified; ignoring batch file" + Project.loadConfig path >>= \case + Left err -> do + print $ pp err + exitFailure + Right config -> + pure (opts { optBatch = InteractiveRepl }, Just config) setupREPL :: Options -> REPL () setupREPL opts = do @@ -281,18 +315,20 @@ setupREPL opts = do Batch file -> prependSearchPath [ takeDirectory file ] _ -> return () - case optLoad opts of - [] -> loadPrelude `REPL.catch` \x -> io $ print $ pp x - [l] -> void (loadCmd l) `REPL.catch` \x -> do - io $ print $ pp x - -- If the requested file fails to load, load the prelude instead... - loadPrelude `REPL.catch` \y -> do - io $ print $ pp y - -- ... but make sure the loaded module is set to the file - -- we tried, instead of the Prelude - REPL.setEditPath l - REPL.setLoadedMod REPL.LoadedModule - { REPL.lFocus = Nothing - , REPL.lPath = InFile l - } - _ -> io $ putStrLn "Only one file may be loaded at the command line." + when (isNothing (optProject opts)) $ + case optLoad opts of + [] -> loadPrelude `REPL.catch` \x -> io $ print $ pp x + [l] -> void (loadCmd l) `REPL.catch` \x -> do + io $ print $ pp x + -- If the requested file fails to load, + -- load the prelude instead... + loadPrelude `REPL.catch` \y -> do + io $ print $ pp y + -- ... but make sure the loaded module is set to the file + -- we tried, instead of the Prelude + REPL.setEditPath l + REPL.setLoadedMod REPL.LoadedModule + { REPL.lFocus = Nothing + , REPL.lPath = InFile l + } + _ -> io $ putStrLn "Only one file may be loaded at the command line." diff --git a/src/Cryptol/Project.hs b/src/Cryptol/Project.hs new file mode 100644 index 000000000..aa4f8349c --- /dev/null +++ b/src/Cryptol/Project.hs @@ -0,0 +1,113 @@ +{-# LANGUAGE BlockArguments #-} +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE DeriveGeneric #-} +{-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE LambdaCase #-} +{-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE RecordWildCards #-} +{-# LANGUAGE TypeApplications #-} +{-# LANGUAGE TypeFamilies #-} + +module Cryptol.Project + ( Config + , loadConfig + , run + ) where + +import Control.Monad.Except +import Data.Aeson +import Data.Functor +import Data.Maybe +import Data.Traversable +import Data.Yaml +import GHC.Generics +import System.Directory +import System.FilePath as FP +import System.IO.Error + +import Data.Foldable + +import Cryptol.ModuleSystem.Base +import Cryptol.ModuleSystem.Env +import Cryptol.ModuleSystem.Monad as M +import Cryptol.Parser.Unlit +import Cryptol.REPL.Command +import Cryptol.REPL.Monad as REPL +import Cryptol.Utils.PP as PP + +type family MaybeIf (opt :: Bool) t where + MaybeIf 'True t = Maybe t + MaybeIf 'False t = t + +data GenericConfig (opt :: Bool) = Config + { root :: MaybeIf opt FilePath + , modules :: MaybeIf opt [FilePath] } + deriving Generic + +type ParsedConfig = GenericConfig 'True +type Config = GenericConfig 'False + +instance FromJSON ParsedConfig where + parseJSON = genericParseJSON defaultOptions { rejectUnknownFields = True } + +data ConfigLoadError = ConfigLoadError FilePath ConfigLoadErrorInfo + +data ConfigLoadErrorInfo + = ConfigParseError ParseException + | SetRootFailed IOError + +instance PP ConfigLoadError where + ppPrec _ (ConfigLoadError path info) = + hang ("Error loading project configuration" <+> text path PP.<.> ":") + 4 (pp info) + +instance PP ConfigLoadErrorInfo where + ppPrec _ (ConfigParseError exn) = + text (prettyPrintParseException exn) + ppPrec _ (SetRootFailed ioe) = + hang "Failed to set project root:" + 4 (text (show ioe)) + +loadConfig :: FilePath -> IO (Either ConfigLoadError Config) +loadConfig path = do + isDir <- doesDirectoryExist path + let filePath = if isDir then path FP. "cryproject.yaml" else path + runExceptT $ withExceptT (ConfigLoadError filePath) do + Config {..} <- withExceptT ConfigParseError do + ExceptT (decodeFileEither @ParsedConfig filePath) + <&> \Config {..} -> Config + { root = fromMaybe "." root + , modules = fromMaybe ["."] modules } :: Config + withExceptT SetRootFailed $ ExceptT $ tryIOError $ + setCurrentDirectory (takeDirectory filePath FP. root) + pure Config {..} + +run :: Config -> REPL CommandResult +run Config {..} = do + minp <- getModuleInput + (res, warnings) <- REPL.io $ runModuleM minp do + let load path = do + isDir <- M.io $ doesDirectoryExist path + if isDir + then M.io (tryIOError (listDirectory path)) >>= \case + Left err -> otherIOError path err + Right entries -> concat <$> for entries \case + '.':_ -> pure [] + entry -> load (path FP. entry) + else case takeExtension path of + '.':ext + | ext `elem` knownExts -> + pure <$> loadModuleByPath True path + _ -> pure [] + concat <$> traverse load modules + printModuleWarnings warnings + case res of + Left err -> do + names <- mctxNameDisp <$> REPL.getFocusedEnv + rPrint $ pp $ ModuleSystemError names err + pure emptyCommandResult { crSuccess = False } + Right (tops, _) -> do + rPutStrLn "all loaded!" + for_ tops \t -> do + rPrint $ pp t + pure emptyCommandResult diff --git a/src/Cryptol/REPL/Command.hs b/src/Cryptol/REPL/Command.hs index c8fa5d0ed..9a81a377a 100644 --- a/src/Cryptol/REPL/Command.hs +++ b/src/Cryptol/REPL/Command.hs @@ -55,6 +55,7 @@ module Cryptol.REPL.Command ( , handleCtrlC , sanitize , withRWTempFile + , printModuleWarnings -- To support Notebook interface (might need to refactor) , replParse @@ -1587,25 +1588,12 @@ getPrimMap :: REPL M.PrimMap getPrimMap = liftModuleCmd M.getPrimMap liftModuleCmd :: M.ModuleCmd a -> REPL a -liftModuleCmd cmd = - do evo <- getEvalOptsAction - env <- getModuleEnv - callStacks <- getCallStacks - tcSolver <- getTCSolver - let minp = - M.ModuleInput - { minpCallStacks = callStacks - , minpEvalOpts = evo - , minpByteReader = BS.readFile - , minpModuleEnv = env - , minpTCSolver = tcSolver - } - moduleCmdResult =<< io (cmd minp) +liftModuleCmd cmd = moduleCmdResult =<< io . cmd =<< getModuleInput -- TODO: add filter for my exhaustie prop guards warning here -moduleCmdResult :: M.ModuleRes a -> REPL a -moduleCmdResult (res,ws0) = do +printModuleWarnings :: [M.ModuleWarning] -> REPL () +printModuleWarnings ws0 = do warnDefaulting <- getKnownUser "warnDefaulting" warnShadowing <- getKnownUser "warnShadowing" warnPrefixAssoc <- getKnownUser "warnPrefixAssoc" @@ -1644,6 +1632,10 @@ moduleCmdResult (res,ws0) = do $ ws0 names <- M.mctxNameDisp <$> getFocusedEnv mapM_ (rPrint . runDoc names . pp) ws + +moduleCmdResult :: M.ModuleRes a -> REPL a +moduleCmdResult (res,ws) = do + printModuleWarnings ws case res of Right (a,me') -> setModuleEnv me' >> return a Left err -> @@ -1655,6 +1647,7 @@ moduleCmdResult (res,ws0) = do do setEditPath file return e _ -> return err + names <- M.mctxNameDisp <$> getFocusedEnv raise (ModuleSystemError names e) diff --git a/src/Cryptol/REPL/Monad.hs b/src/Cryptol/REPL/Monad.hs index 47900b1ac..16f09eeba 100644 --- a/src/Cryptol/REPL/Monad.hs +++ b/src/Cryptol/REPL/Monad.hs @@ -63,6 +63,7 @@ module Cryptol.REPL.Monad ( , withRandomGen , setRandomGen , getRandomGen + , getModuleInput -- ** Config Options , EnvVal(..) @@ -127,6 +128,7 @@ import Control.Monad.Base import qualified Control.Monad.Catch as Ex import Control.Monad.IO.Class import Control.Monad.Trans.Control +import qualified Data.ByteString as BS import Data.Char (isSpace, toLower) import Data.IORef (IORef,newIORef,readIORef,atomicModifyIORef) @@ -702,6 +704,20 @@ withRandomGen repl = setRandomGen g' pure result +getModuleInput :: REPL (M.ModuleInput IO) +getModuleInput = do + evo <- getEvalOptsAction + env <- getModuleEnv + callStacks <- getCallStacks + tcSolver <- getTCSolver + pure M.ModuleInput + { minpCallStacks = callStacks + , minpEvalOpts = evo + , minpByteReader = BS.readFile + , minpModuleEnv = env + , minpTCSolver = tcSolver + } + -- | Given an existing qualified name, prefix it with a -- relatively-unique string. We make it unique by prefixing with a -- character @#@ that is not lexically valid in a module name. From 2191f4d2fd322073ad2427848479bbe4f2e0e19d Mon Sep 17 00:00:00 2001 From: Bretton Date: Wed, 21 Jun 2023 14:30:34 -0700 Subject: [PATCH 07/35] Revert "Update tests for Main module name change" This reverts commit 6674db149689bb3d84b5442f74c5adcc5b1a4ecf. --- examples/AE.cry | 1 - tests/constraint-guards/constant.icry.stdout | 4 +- tests/constraint-guards/inits.icry.stdout | 2 +- tests/constraint-guards/insert.icry.stdout | 2 +- tests/constraint-guards/len.icry.stdout | 2 +- tests/constraint-guards/mergesort.icry.stdout | 2 +- tests/constraint-guards/nestFun.icry.stdout | 2 +- tests/constraint-guards/nestMod.icry.stdout | 2 +- tests/constraint-guards/noNested.icry.stdout | 2 +- tests/constraint-guards/noPrim.icry.stdout | 2 +- tests/constraint-guards/tail.icry.stdout | 2 +- tests/examples/allexamples.icry.stdout | 46 +++++++++---------- tests/ffi/ffi-header.icry.stdout | 2 +- tests/ffi/ffi-no-dup.icry.stdout | 4 +- tests/ffi/ffi-no-functor.icry.stdout | 4 +- tests/ffi/ffi-reload.icry.stdout | 4 +- tests/ffi/ffi-runtime-errors.icry.stdout | 14 +++--- tests/ffi/ffi-type-errors.icry.stdout | 18 ++++---- tests/ffi/test-ffi.icry.stdout | 2 +- tests/issues/T1440.cry | 2 - tests/issues/T1440.icry.stdout | 10 ++-- tests/issues/T146.icry.stdout | 6 +-- tests/issues/T1494_1.cry | 1 - tests/issues/T1494_1.icry.stdout | 4 +- tests/issues/issue006.icry.stdout | 2 +- tests/issues/issue058.icry.stdout | 8 ++-- tests/issues/issue081.icry.stdout | 2 +- tests/issues/issue083.icry.stdout | 2 +- tests/issues/issue093.icry.stdout | 2 +- tests/issues/issue1024.icry.stdout | 4 +- tests/issues/issue108.icry.stdout | 8 ++-- tests/issues/issue116.icry.stdout | 2 +- tests/issues/issue1191.icry.stdout | 2 +- tests/issues/issue1210.icry.stdout | 2 +- tests/issues/issue126.icry.stdout | 2 +- tests/issues/issue128.icry.stdout | 2 +- tests/issues/issue130.icry.stdout | 2 +- tests/issues/issue1324.icry.stdout | 4 +- tests/issues/issue133.icry.stdout | 2 +- tests/issues/issue1344.icry.stdout | 2 +- tests/issues/issue138.icry.stdout | 2 +- tests/issues/issue141.icry.stdout | 2 +- tests/issues/issue1441_a.icry.stdout | 2 +- tests/issues/issue1441_b.icry.stdout | 2 +- tests/issues/issue148.icry.stdout | 2 +- tests/issues/issue150.icry.stdout | 2 +- tests/issues/issue1502.icry.stdout | 2 +- tests/issues/issue1503.icry.stdout | 2 +- tests/issues/issue158.icry.stdout | 2 +- tests/issues/issue160.icry.stdout | 2 +- tests/issues/issue171.icry.stdout | 2 +- tests/issues/issue184.icry.stdout | 2 +- tests/issues/issue185.icry.stdout | 2 +- tests/issues/issue198.icry.stdout | 2 +- tests/issues/issue212.icry.stdout | 2 +- tests/issues/issue214.icry.stdout | 2 +- tests/issues/issue268.icry.stdout | 2 +- tests/issues/issue290v2.icry.stdout | 6 +-- tests/issues/issue304.icry.stdout | 2 +- tests/issues/issue308.icry.stdout | 2 +- tests/issues/issue312.icry.stdout | 2 +- tests/issues/issue314.icry.stdout | 2 +- tests/issues/issue323.icry.stdout | 4 +- tests/issues/issue364.icry.stdout | 2 +- tests/issues/issue368.icry.stdout | 2 +- tests/issues/issue389.icry.stdout | 2 +- tests/issues/issue416.icry.stdout | 6 +-- tests/issues/issue494.icry.stdout | 2 +- tests/issues/issue513.icry.stdout | 20 ++++---- tests/issues/issue581.icry.stdout | 2 +- tests/issues/issue582.icry.stdout | 6 +-- tests/issues/issue614.icry.stdout | 2 +- tests/issues/issue640.icry.stdout | 2 +- tests/issues/issue662.icry.stdout | 2 +- tests/issues/issue670.icry.stdout | 2 +- tests/issues/issue68.icry.stdout | 2 +- tests/issues/issue723.icry.stdout | 2 +- tests/issues/issue731.cry | 2 - tests/issues/issue731.icry | 2 +- tests/issues/issue731.icry.stdout | 2 +- tests/issues/issue734.icry.stdout | 2 +- tests/issues/issue78.icry.stdout | 2 +- tests/issues/issue826.icry.stdout | 2 +- tests/issues/issue845.icry.stdout | 4 +- tests/issues/issue850.icry.stdout | 2 +- tests/issues/issue851.icry.stdout | 2 +- tests/issues/issue852.icry.stdout | 2 +- tests/issues/issue877.icry.stdout | 2 +- tests/issues/issue894.icry.stdout | 2 +- tests/issues/issue962.icry.stdout | 4 +- tests/issues/trac133.icry.stdout | 2 +- tests/issues/trac289.icry.stdout | 2 +- tests/modsys/T1330.icry.stdout | 2 +- tests/modsys/functors/T001.icry.stdout | 2 +- tests/modsys/functors/T002.icry.stdout | 2 +- tests/modsys/functors/T003.icry.stdout | 2 +- tests/modsys/functors/T004.icry.stdout | 2 +- tests/modsys/functors/T005.icry.stdout | 2 +- tests/modsys/functors/T006.icry.stdout | 2 +- tests/modsys/functors/T007.icry.stdout | 2 +- tests/modsys/functors/T008.icry.stdout | 2 +- tests/modsys/functors/T009.icry.stdout | 2 +- tests/modsys/functors/T011.icry.stdout | 2 +- tests/modsys/functors/T012.icry.stdout | 2 +- tests/modsys/functors/T013.icry.stdout | 4 +- tests/modsys/functors/T014.icry.stdout | 4 +- tests/modsys/functors/T015.icry.stdout | 2 +- tests/modsys/functors/T016.icry.stdout | 2 +- tests/modsys/functors/T021.icry.stdout | 2 +- tests/modsys/functors/T022.icry.stdout | 2 +- tests/modsys/functors/T025.icry.stdout | 2 +- tests/modsys/functors/T026.icry.stdout | 2 +- tests/modsys/functors/T027.icry.stdout | 2 +- tests/modsys/functors/T028.icry.stdout | 2 +- tests/modsys/functors/T029.icry.stdout | 2 +- tests/modsys/functors/T031.icry.stdout | 2 +- tests/modsys/functors/T033.icry.stdout | 2 +- tests/modsys/functors/T035.icry.stdout | 8 ++-- tests/modsys/functors/T040.icry.stdout | 2 +- tests/modsys/nested/T16.icry.stdout | 2 +- tests/modsys/nested/T7.icry.stdout | 2 +- tests/parser/T437.icry.stdout | 2 +- tests/parser/docs.icry.stdout | 2 +- tests/parser/infix-1.icry.stdout | 2 +- tests/parser/infix-2.icry.stdout | 2 +- tests/parser/infix-3.icry.stdout | 2 +- tests/parser/unary-2.icry.stdout | 2 +- tests/parser/unary.icry.stdout | 2 +- tests/regression/EvenMansour.icry.stdout | 2 +- tests/regression/allsat.icry.stdout | 2 +- tests/regression/bitshift.icry.stdout | 2 +- tests/regression/bvdiv.icry.stdout | 2 +- tests/regression/check01.icry.stdout | 2 +- tests/regression/check02.icry.stdout | 4 +- tests/regression/check03.icry.stdout | 2 +- tests/regression/check04.icry.stdout | 4 +- tests/regression/check05.icry.stdout | 4 +- tests/regression/check06.icry.stdout | 4 +- tests/regression/check07.icry.stdout | 2 +- tests/regression/check08.icry.stdout | 2 +- tests/regression/check09.icry.stdout | 2 +- tests/regression/check10.icry.stdout | 2 +- tests/regression/check11.icry.stdout | 2 +- tests/regression/check12.icry.stdout | 2 +- tests/regression/check13.icry.stdout | 2 +- tests/regression/check14.icry.stdout | 2 +- tests/regression/check15.icry.stdout | 2 +- tests/regression/check16-tab.icry.stdout | 2 +- tests/regression/check16.icry.stdout | 2 +- tests/regression/check17.icry.stdout | 2 +- tests/regression/check18.icry.stdout | 2 +- tests/regression/check19.icry.stdout | 2 +- tests/regression/check20.icry.stdout | 2 +- tests/regression/check21.icry.stdout | 2 +- tests/regression/check22.icry.stdout | 2 +- tests/regression/check23.icry.stdout | 2 +- tests/regression/check24.icry.stdout | 2 +- tests/regression/check26.icry.stdout | 2 +- tests/regression/check27.icry.stdout | 2 +- tests/regression/check28.icry.stdout | 2 +- tests/regression/check29.icry.stdout | 2 +- tests/regression/check30.icry.stdout | 4 +- tests/regression/cplx.icry.stdout | 4 +- tests/regression/dumptests.icry.stdout | 2 +- tests/regression/f2polytest.icry.stdout | 2 +- tests/regression/negshift.icry.stdout | 2 +- tests/regression/poly.icry.stdout | 2 +- tests/regression/primes.icry.stdout | 2 +- tests/regression/r01.icry.stdout | 2 +- tests/regression/r05.icry.stdout | 2 +- .../rational_properties.icry.stdout | 2 +- tests/regression/rec-update.icry.stdout | 2 +- tests/regression/reference.icry.stdout | 2 +- tests/regression/tc-errors.icry.stdout | 18 ++++---- tests/regression/twinmult.icry.stdout | 2 +- tests/regression/word-update.icry.stdout | 2 +- tests/regression/xor-precedence.icry.stdout | 2 +- tests/suiteb/ECDSAKeyPair.icry.stdout | 2 +- tests/suiteb/ECDSASigGen.icry.stdout | 2 +- tests/suiteb/ECDSASigVerify.icry.stdout | 2 +- tests/suiteb/aes-mct-ecb.icry.stdout | 2 +- tests/suiteb/aes-vectors.icry.stdout | 2 +- tests/suiteb/sha224-mct.icry.stdout | 2 +- tests/suiteb/sha224-vectors-long.icry.stdout | 2 +- tests/suiteb/sha224-vectors-short.icry.stdout | 2 +- tests/suiteb/sha256-mct.icry.stdout | 2 +- tests/suiteb/sha256-vectors-long.icry.stdout | 2 +- tests/suiteb/sha256-vectors-short.icry.stdout | 2 +- tests/suiteb/sha384-mct.icry.stdout | 2 +- tests/suiteb/sha384-vectors-long.icry.stdout | 2 +- tests/suiteb/sha384-vectors-short.icry.stdout | 2 +- tests/suiteb/sha512-mct.icry.stdout | 2 +- tests/suiteb/sha512-vectors-long.icry.stdout | 2 +- tests/suiteb/sha512-vectors-short.icry.stdout | 2 +- 194 files changed, 282 insertions(+), 288 deletions(-) diff --git a/examples/AE.cry b/examples/AE.cry index 333e4b051..1ac25e774 100644 --- a/examples/AE.cry +++ b/examples/AE.cry @@ -5,7 +5,6 @@ Implementation of the algorithms from the paper "Automated Analysis and Synthesis of Authenticated Encryption Schemes" by Viet Tung Hoang, Jonathan Katz, and Alex J. Malozemoff */ -module AE where parameter type A : * // State type diff --git a/tests/constraint-guards/constant.icry.stdout b/tests/constraint-guards/constant.icry.stdout index d2274d67e..8f64c6d74 100644 --- a/tests/constraint-guards/constant.icry.stdout +++ b/tests/constraint-guards/constant.icry.stdout @@ -1,12 +1,12 @@ Loading module Cryptol Loading module Cryptol -Loading module [constant.cry] +Loading module Main [warning] at constant.cry:1:11--1:16 Unused name: n [warning] at constant.cry:14:10--14:15 Unused name: n [warning] at constant.cry:28:1--28:10: - Could not prove that the constraint guards used in defining [constant.cry]::idTypeNum were exhaustive. + Could not prove that the constraint guards used in defining Main::idTypeNum were exhaustive. property isZero_correct Using exhaustive testing. Testing... Passed 1 tests. Q.E.D. diff --git a/tests/constraint-guards/inits.icry.stdout b/tests/constraint-guards/inits.icry.stdout index 12fe88f3a..b5aac7865 100644 --- a/tests/constraint-guards/inits.icry.stdout +++ b/tests/constraint-guards/inits.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module [inits.cry] +Loading module Main Showing a specific instance of polymorphic result: * Using 'Integer' for type of sequence member Using exhaustive testing. diff --git a/tests/constraint-guards/insert.icry.stdout b/tests/constraint-guards/insert.icry.stdout index 5016fbee4..d80fdf123 100644 --- a/tests/constraint-guards/insert.icry.stdout +++ b/tests/constraint-guards/insert.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module [insert.cry] +Loading module Main Using exhaustive testing. Testing... Passed 1 tests. Q.E.D. diff --git a/tests/constraint-guards/len.icry.stdout b/tests/constraint-guards/len.icry.stdout index 30fcf79b4..d80fdf123 100644 --- a/tests/constraint-guards/len.icry.stdout +++ b/tests/constraint-guards/len.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module [len.cry] +Loading module Main Using exhaustive testing. Testing... Passed 1 tests. Q.E.D. diff --git a/tests/constraint-guards/mergesort.icry.stdout b/tests/constraint-guards/mergesort.icry.stdout index 8bf8ce0cb..b5aac7865 100644 --- a/tests/constraint-guards/mergesort.icry.stdout +++ b/tests/constraint-guards/mergesort.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module [mergesort.cry] +Loading module Main Showing a specific instance of polymorphic result: * Using 'Integer' for type of sequence member Using exhaustive testing. diff --git a/tests/constraint-guards/nestFun.icry.stdout b/tests/constraint-guards/nestFun.icry.stdout index 20b4d54ab..6e8b4478b 100644 --- a/tests/constraint-guards/nestFun.icry.stdout +++ b/tests/constraint-guards/nestFun.icry.stdout @@ -1,5 +1,5 @@ Loading module Cryptol Loading module Cryptol -Loading module [nestFun.cry] +Loading module Main False True diff --git a/tests/constraint-guards/nestMod.icry.stdout b/tests/constraint-guards/nestMod.icry.stdout index 9cf07049a..27a449bc0 100644 --- a/tests/constraint-guards/nestMod.icry.stdout +++ b/tests/constraint-guards/nestMod.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module [nestMod.cry] +Loading module Main [warning] at nestMod.cry:8:5--8:13: Assuming n to have a numeric type [warning] at nestMod.cry:4:7--4:15: diff --git a/tests/constraint-guards/noNested.icry.stdout b/tests/constraint-guards/noNested.icry.stdout index 0bb6114fb..f9c19b600 100644 --- a/tests/constraint-guards/noNested.icry.stdout +++ b/tests/constraint-guards/noNested.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module [noNested.cry] +Loading module Main At noNested.cry:6:3--6:9: Local declaration `nested` may not use constraint guards. diff --git a/tests/constraint-guards/noPrim.icry.stdout b/tests/constraint-guards/noPrim.icry.stdout index c6d3adcc6..7fc76db1f 100644 --- a/tests/constraint-guards/noPrim.icry.stdout +++ b/tests/constraint-guards/noPrim.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module [noPrim.cry] +Loading module Main [error] at noPrim.cry:3:7--3:14: `prime` may not be used in a constraint guard. diff --git a/tests/constraint-guards/tail.icry.stdout b/tests/constraint-guards/tail.icry.stdout index b6a0812a6..b5aac7865 100644 --- a/tests/constraint-guards/tail.icry.stdout +++ b/tests/constraint-guards/tail.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module [tail.cry] +Loading module Main Showing a specific instance of polymorphic result: * Using 'Integer' for type of sequence member Using exhaustive testing. diff --git a/tests/examples/allexamples.icry.stdout b/tests/examples/allexamples.icry.stdout index abe306a29..c5972d2b7 100644 --- a/tests/examples/allexamples.icry.stdout +++ b/tests/examples/allexamples.icry.stdout @@ -1,7 +1,7 @@ Loading module Cryptol Loading module Cryptol -Loading interface module `parameter` interface of AE -Loading module AE +Loading interface module `parameter` interface of Main +Loading module Main Loading module Cryptol Loading module AES Loading module Cryptol @@ -32,54 +32,54 @@ Loading module Cryptol Loading module Cipher Loading module Test Loading module Cryptol -Loading module [append.cry] +Loading module Main Loading module Cryptol -Loading module [builtin_lifting.cry] +Loading module Main Loading module Cryptol -Loading module [builtins.cry] +Loading module Main Loading module Cryptol -Loading module [comp.cry] +Loading module Main Loading module Cryptol -Loading module [demote.cry] +Loading module Main Loading module Cryptol -Loading module [inflist.cry] +Loading module Main Loading module Cryptol -Loading module [mini.cry] +Loading module Main Loading module Cryptol -Loading module [props.cry] +Loading module Main Loading module Cryptol -Loading module [split.cry] +Loading module Main Loading module Cryptol -Loading module [splitAt.cry] +Loading module Main Loading module Cryptol -Loading module [width.cry] +Loading module Main Loading module Cryptol -Loading module [xor_cipher.cry] +Loading module Main Loading module Cryptol -Loading module [zero_weird.cry] +Loading module Main Loading module Cryptol -Loading module [contrib/A51.cry] +Loading module Main Loading module Cryptol Loading module Cipher Loading module CAST5 Loading module Cryptol -Loading module [contrib/EvenMansour.cry] +Loading module Main Loading module Cryptol Loading module MISTY1 Loading module Cryptol -Loading module [contrib/RC4.cry] +Loading module Main Loading module Cryptol Loading module MKRAND Loading module Cryptol -Loading module [funstuff/Coins.cry] +Loading module Main Loading module Cryptol Loading module FoxChickenCorn Loading module Cryptol -Loading module [funstuff/NQueens.cry] +Loading module Main Loading module Cryptol -Loading module [funstuff/marble.cry] +Loading module Main Loading module Cryptol -Loading module [maliciousSHA/malicious_SHA1.cry] +Loading module Main Loading module Cryptol Loading module AES::GF28 Loading module AES::State @@ -110,7 +110,7 @@ Loading interface module `parameter` interface of AES::ExpandKey Loading module AES::ExpandKey Loading module AES Loading module Common::AES_GCM_SIV -Loading module [param_modules/AES_GCM_SIV_Test.cry] +Loading module Main Loading module Cryptol Loading module AES::GF28 Loading module AES::State diff --git a/tests/ffi/ffi-header.icry.stdout b/tests/ffi/ffi-header.icry.stdout index bf93c0ab9..d3744a160 100644 --- a/tests/ffi/ffi-header.icry.stdout +++ b/tests/ffi/ffi-header.icry.stdout @@ -1,4 +1,4 @@ Loading module Cryptol Loading module Float -Loading module [test-ffi2.cry] +Loading module Main Writing header to test-ffi2.h diff --git a/tests/ffi/ffi-no-dup.icry.stdout b/tests/ffi/ffi-no-dup.icry.stdout index 7a082ae24..5cca6738f 100644 --- a/tests/ffi/ffi-no-dup.icry.stdout +++ b/tests/ffi/ffi-no-dup.icry.stdout @@ -1,8 +1,8 @@ Loading module Cryptol Loading module Cryptol -Loading module [ffi-no-dup.cry] +Loading module Main -[error] Failed to load foreign implementations for module [ffi-no-dup.cry]: +[error] Failed to load foreign implementations for module Main: Multiple foreign declarations with the same name: `f` defined at ffi-no-dup.cry:6:11--6:12 ffi-no-dup.cry:3:9--3:10 diff --git a/tests/ffi/ffi-no-functor.icry.stdout b/tests/ffi/ffi-no-functor.icry.stdout index 2bb94b138..509b2a107 100644 --- a/tests/ffi/ffi-no-functor.icry.stdout +++ b/tests/ffi/ffi-no-functor.icry.stdout @@ -1,7 +1,7 @@ Loading module Cryptol Loading module Cryptol -Loading module [ffi-no-functor.cry] +Loading module Main -[error] Failed to load foreign implementations for module [ffi-no-functor.cry]: +[error] Failed to load foreign implementations for module Main: ffi-no-functor.cry:6:11--6:12: Foreign declaration `f` may not appear in a parameterized module. diff --git a/tests/ffi/ffi-reload.icry.stdout b/tests/ffi/ffi-reload.icry.stdout index b03f3f414..ed065cd07 100644 --- a/tests/ffi/ffi-reload.icry.stdout +++ b/tests/ffi/ffi-reload.icry.stdout @@ -1,9 +1,9 @@ Loading module Cryptol Loading module Cryptol -Loading module [ffi-reload.cry] +Loading module Main Loading dynamic library ffi-reload.so False Loading module Cryptol -Loading module [ffi-reload.cry] +Loading module Main Loading dynamic library ffi-reload.so True diff --git a/tests/ffi/ffi-runtime-errors.icry.stdout b/tests/ffi/ffi-runtime-errors.icry.stdout index 873da4fa1..19f17e108 100644 --- a/tests/ffi/ffi-runtime-errors.icry.stdout +++ b/tests/ffi/ffi-runtime-errors.icry.stdout @@ -1,29 +1,29 @@ Loading module Cryptol Loading module Cryptol -Loading module [ffi-runtime-errors.cry] +Loading module Main Loading dynamic library ffi-runtime-errors.so numeric type argument to foreign function is too large: 18446744073709551616 -in type parameter n`899 of function [ffi-runtime-errors.cry]::f +in type parameter n`899 of function Main::f type arguments must fit in a C `size_t` -- Backtrace -- -[ffi-runtime-errors.cry]::f called at ffi-runtime-errors.icry:4:1--4:2 +Main::f called at ffi-runtime-errors.icry:4:1--4:2 -cannot call foreign function [ffi-runtime-errors.cry]::g +cannot call foreign function Main::g FFI calls are not supported in this context If you are trying to evaluate an expression, try rebuilding Cryptol with FFI support enabled. -cannot call foreign function [ffi-runtime-errors.cry]::g +cannot call foreign function Main::g FFI calls are not supported in this context If you are trying to evaluate an expression, try rebuilding Cryptol with FFI support enabled. -cannot call foreign function [ffi-runtime-errors.cry]::g +cannot call foreign function Main::g FFI calls are not supported in this context If you are trying to evaluate an expression, try rebuilding Cryptol with FFI support enabled. -cannot call foreign function [ffi-runtime-errors.cry]::g +cannot call foreign function Main::g FFI calls are not supported in this context If you are trying to evaluate an expression, try rebuilding Cryptol with FFI support enabled. diff --git a/tests/ffi/ffi-type-errors.icry.stdout b/tests/ffi/ffi-type-errors.icry.stdout index 4e43f60bb..f808f915e 100644 --- a/tests/ffi/ffi-type-errors.icry.stdout +++ b/tests/ffi/ffi-type-errors.icry.stdout @@ -1,7 +1,7 @@ Loading module Cryptol Loading module Cryptol Loading module Float -Loading module [ffi-type-errors.cry] +Loading module Main [error] at ffi-type-errors.cry:3:9--3:37: Type unsupported for FFI: @@ -17,7 +17,7 @@ Loading module [ffi-type-errors.cry] Due to: Unsupported word size Only words of up to 64 bits are supported - When checking the type of '[ffi-type-errors.cry]::badWordSizes' + When checking the type of 'Main::badWordSizes' [error] at ffi-type-errors.cry:4:9--4:44: Type unsupported for FFI: Float 5 11 -> Float 15 113 @@ -32,7 +32,7 @@ Loading module [ffi-type-errors.cry] Due to: Unsupported Float format Only Float32 and Float64 are supported - When checking the type of '[ffi-type-errors.cry]::badFloatSizes' + When checking the type of 'Main::badFloatSizes' [error] at ffi-type-errors.cry:5:9--6:59: Type unsupported for FFI: [n`962] -> [n`962]([16], [16]) -> [n`962][4][8]{a : [n`962], @@ -56,33 +56,33 @@ Loading module [ffi-type-errors.cry] Unsupported sequence element type Only words or floats are supported as the element type of (possibly multidimensional) sequences - When checking the type of '[ffi-type-errors.cry]::badArrayTypes' + When checking the type of 'Main::badArrayTypes' [error] at ffi-type-errors.cry:7:9--7:27: Type unsupported for FFI: [32] Due to: FFI binding must be a function - When checking the type of '[ffi-type-errors.cry]::notFunction' + When checking the type of 'Main::notFunction' [error] at ffi-type-errors.cry:8:9--8:32: Kind of type variable unsupported for FFI: t`963 : * Only type variables of kind # are supported - When checking the type of '[ffi-type-errors.cry]::badKind' + When checking the type of 'Main::badKind' [error] at ffi-type-errors.cry:9:9--9:43: Failed to validate user-specified signature. - in the definition of '[ffi-type-errors.cry]::noFin', at ffi-type-errors.cry:9:9--9:14, + in the definition of 'Main::noFin', at ffi-type-errors.cry:9:9--9:14, we need to show that for any type n the following constraints hold: • fin n arising from - declaration of foreign function [ffi-type-errors.cry]::noFin + declaration of foreign function Main::noFin at ffi-type-errors.cry:9:9--9:43 [error] at ffi-type-errors.cry:10:9--10:34: • Unsolvable constraint: fin inf arising from - declaration of foreign function [ffi-type-errors.cry]::infSeq + declaration of foreign function Main::infSeq at ffi-type-errors.cry:10:9--10:34 [error] at ffi-type-errors.cry:11:48--11:49: Wild card types are not allowed in this context diff --git a/tests/ffi/test-ffi.icry.stdout b/tests/ffi/test-ffi.icry.stdout index e253f18f8..920a3bccd 100644 --- a/tests/ffi/test-ffi.icry.stdout +++ b/tests/ffi/test-ffi.icry.stdout @@ -1,7 +1,7 @@ Loading module Cryptol Loading module Cryptol Loading module Float -Loading module [test-ffi.cry] +Loading module Main Loading dynamic library test-ffi.so 0x03 0x15b4 diff --git a/tests/issues/T1440.cry b/tests/issues/T1440.cry index 86e51e877..089285c1e 100644 --- a/tests/issues/T1440.cry +++ b/tests/issues/T1440.cry @@ -1,5 +1,3 @@ -module T1440 where - import interface submodule X import submodule Y diff --git a/tests/issues/T1440.icry.stdout b/tests/issues/T1440.icry.stdout index d74531fc9..12b4d1ca6 100644 --- a/tests/issues/T1440.icry.stdout +++ b/tests/issues/T1440.icry.stdout @@ -1,12 +1,12 @@ Loading module Cryptol Loading module Cryptol -Loading module T1440 +Loading module Main -[error] at T1440.cry:3:28--3:29 +[error] at T1440.cry:1:28--1:29 Module not in scope: X -[error] at T1440.cry:5:1--5:19 +[error] at T1440.cry:3:1--3:19 Module not in scope: Y -[error] at T1440.cry:16:40--16:42 +[error] at T1440.cry:14:40--14:42 Module not in scope: U1 -[error] at T1440.cry:17:26--17:28 +[error] at T1440.cry:15:26--15:28 Module not in scope: U2 diff --git a/tests/issues/T146.icry.stdout b/tests/issues/T146.icry.stdout index 6951ba53f..d189b790b 100644 --- a/tests/issues/T146.icry.stdout +++ b/tests/issues/T146.icry.stdout @@ -1,18 +1,18 @@ Loading module Cryptol Loading module Cryptol -Loading module [T146.cry] +Loading module Main [error] at T146.cry:11:10--11:12: The type ?b is not sufficiently polymorphic. It cannot depend on quantified variables: fv`895 When checking signature variable 'fv' where - ?b is type argument 'fv' of '[T146.cry]::ec_v2' at T146.cry:5:19--5:24 + ?b is type argument 'fv' of 'Main::ec_v2' at T146.cry:5:19--5:24 fv`902 is signature variable 'fv' at T146.cry:11:10--11:12 [error] at T146.cry:12:11--12:21: The type ?a is not sufficiently polymorphic. It cannot depend on quantified variables: fv`895 When checking type of field 'v0' where - ?a is type argument 'fv' of '[T146.cry]::ec_v1' at T146.cry:4:19--4:24 + ?a is type argument 'fv' of 'Main::ec_v1' at T146.cry:4:19--4:24 fv`902 is signature variable 'fv' at T146.cry:11:10--11:12 diff --git a/tests/issues/T1494_1.cry b/tests/issues/T1494_1.cry index 621d6014a..d60028501 100644 --- a/tests/issues/T1494_1.cry +++ b/tests/issues/T1494_1.cry @@ -1,4 +1,3 @@ -module T1494_1 where parameter type n : # diff --git a/tests/issues/T1494_1.icry.stdout b/tests/issues/T1494_1.icry.stdout index 90190df26..f57e993b3 100644 --- a/tests/issues/T1494_1.icry.stdout +++ b/tests/issues/T1494_1.icry.stdout @@ -1,4 +1,4 @@ Loading module Cryptol Loading module Cryptol -Loading interface module `parameter` interface of T1494_1 -Loading module T1494_1 +Loading interface module `parameter` interface of Main +Loading module Main diff --git a/tests/issues/issue006.icry.stdout b/tests/issues/issue006.icry.stdout index a13a91192..c7a365c1b 100644 --- a/tests/issues/issue006.icry.stdout +++ b/tests/issues/issue006.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module [issue006.cry] +Loading module Main 0x00000008 0x00000008 0x00000000 diff --git a/tests/issues/issue058.icry.stdout b/tests/issues/issue058.icry.stdout index 1d532f593..cd2df137a 100644 --- a/tests/issues/issue058.icry.stdout +++ b/tests/issues/issue058.icry.stdout @@ -1,10 +1,10 @@ Loading module Cryptol Loading module Cryptol -Loading module [issue058.cry] +Loading module Main [error] at issue058.cry:4:1--4:16: Failed to validate user-specified signature. - in the definition of '[issue058.cry]::some', at issue058.cry:4:1--4:5, + in the definition of 'Main::some', at issue058.cry:4:1--4:5, we need to show that for any type n the following constraints hold: @@ -14,7 +14,7 @@ Loading module [issue058.cry] at issue058.cry:4:10--4:16 [error] at issue058.cry:7:1--7:17: Failed to validate user-specified signature. - in the definition of '[issue058.cry]::last', at issue058.cry:7:1--7:5, + in the definition of 'Main::last', at issue058.cry:7:1--7:5, we need to show that for any type n, a assuming @@ -26,7 +26,7 @@ Loading module [issue058.cry] at issue058.cry:7:11--7:17 [error] at issue058.cry:10:1--10:17: Failed to validate user-specified signature. - in the definition of '[issue058.cry]::pad', at issue058.cry:10:1--10:4, + in the definition of 'Main::pad', at issue058.cry:10:1--10:4, we need to show that for any type n the following constraints hold: diff --git a/tests/issues/issue081.icry.stdout b/tests/issues/issue081.icry.stdout index 751cde6a6..64f2eb8e2 100644 --- a/tests/issues/issue081.icry.stdout +++ b/tests/issues/issue081.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module [issue081.cry] +Loading module Main 0x2 0xb 0x2 diff --git a/tests/issues/issue083.icry.stdout b/tests/issues/issue083.icry.stdout index eb4c7608d..57a1d7a1c 100644 --- a/tests/issues/issue083.icry.stdout +++ b/tests/issues/issue083.icry.stdout @@ -1,3 +1,3 @@ Loading module Cryptol Loading module Cryptol -Loading module [issue083.cry] +Loading module Main diff --git a/tests/issues/issue093.icry.stdout b/tests/issues/issue093.icry.stdout index f33cb8266..1aef8e83f 100644 --- a/tests/issues/issue093.icry.stdout +++ b/tests/issues/issue093.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module [issue093.cry] +Loading module Main property t0 Using exhaustive testing. Testing... Passed 1 tests. Q.E.D. diff --git a/tests/issues/issue1024.icry.stdout b/tests/issues/issue1024.icry.stdout index e5b7474bc..491e08fcc 100644 --- a/tests/issues/issue1024.icry.stdout +++ b/tests/issues/issue1024.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module [issue1024a.cry] +Loading module Main [warning] at issue1024a.cry:1:13--1:14 Unused name: f [warning] at issue1024a.cry:2:15--2:16 @@ -28,5 +28,5 @@ Loading module [issue1024a.cry] where f`895 is signature variable 'f' at issue1024a.cry:4:22--4:32 Loading module Cryptol -Loading module [issue1024b.cry] +Loading module Main 0xffff diff --git a/tests/issues/issue108.icry.stdout b/tests/issues/issue108.icry.stdout index 28e085118..06998eae0 100644 --- a/tests/issues/issue108.icry.stdout +++ b/tests/issues/issue108.icry.stdout @@ -1,13 +1,13 @@ Loading module Cryptol Loading module Cryptol -Loading module [issue108.cry] +Loading module Main Showing a specific instance of polymorphic result: - * Using '0' for type argument 'b' of '[issue108.cry]::sum' + * Using '0' for type argument 'b' of 'Main::sum' 0x0 Showing a specific instance of polymorphic result: - * Using '2' for type argument 'b' of '[issue108.cry]::sum' + * Using '2' for type argument 'b' of 'Main::sum' 0x2 Showing a specific instance of polymorphic result: - * Using '4' for type argument 'b' of '[issue108.cry]::sum' + * Using '4' for type argument 'b' of 'Main::sum' 0x7 0x37 diff --git a/tests/issues/issue116.icry.stdout b/tests/issues/issue116.icry.stdout index ff2cd61d3..cdd08d402 100644 --- a/tests/issues/issue116.icry.stdout +++ b/tests/issues/issue116.icry.stdout @@ -1,4 +1,4 @@ Loading module Cryptol Loading module Cryptol -Loading module [issue116.cry] +Loading module Main True diff --git a/tests/issues/issue1191.icry.stdout b/tests/issues/issue1191.icry.stdout index 3d7033b3d..c22d89ac2 100644 --- a/tests/issues/issue1191.icry.stdout +++ b/tests/issues/issue1191.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module [issue1191.cry] +Loading module Main 0xeadbeefd 0xeadbeefd 0xeadbeefd diff --git a/tests/issues/issue1210.icry.stdout b/tests/issues/issue1210.icry.stdout index beec6a871..e49d356ca 100644 --- a/tests/issues/issue1210.icry.stdout +++ b/tests/issues/issue1210.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module [issue1210.cry] +Loading module Main property mwe Using exhaustive testing. Testing... Passed 16 tests. Q.E.D. diff --git a/tests/issues/issue126.icry.stdout b/tests/issues/issue126.icry.stdout index ece5f9b17..57a1d7a1c 100644 --- a/tests/issues/issue126.icry.stdout +++ b/tests/issues/issue126.icry.stdout @@ -1,3 +1,3 @@ Loading module Cryptol Loading module Cryptol -Loading module [issue126.cry] +Loading module Main diff --git a/tests/issues/issue128.icry.stdout b/tests/issues/issue128.icry.stdout index 9c9bf09d6..66dd1b30f 100644 --- a/tests/issues/issue128.icry.stdout +++ b/tests/issues/issue128.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module [issue128.cry] +Loading module Main Using exhaustive testing. Testing... Passed 1 tests. Q.E.D. diff --git a/tests/issues/issue130.icry.stdout b/tests/issues/issue130.icry.stdout index a4ce9ab43..4bdbd4b26 100644 --- a/tests/issues/issue130.icry.stdout +++ b/tests/issues/issue130.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module [issue130.cry] +Loading module Main Using exhaustive testing. Testing... Passed 8 tests. Q.E.D. diff --git a/tests/issues/issue1324.icry.stdout b/tests/issues/issue1324.icry.stdout index 140324ab3..a80deb48e 100644 --- a/tests/issues/issue1324.icry.stdout +++ b/tests/issues/issue1324.icry.stdout @@ -1,10 +1,10 @@ Loading module Cryptol Loading module Cryptol -Loading module [issue1324.cry] +Loading module Main [error] at issue1324.cry:8:1--8:6: Type mismatch: Expected type: 16 Inferred type: 8 Context: {a : [ERROR] _, …} -> _ - When checking the type of '[issue1324.cry]::g' + When checking the type of 'Main::g' diff --git a/tests/issues/issue133.icry.stdout b/tests/issues/issue133.icry.stdout index 1a02da4b5..f47a85504 100644 --- a/tests/issues/issue133.icry.stdout +++ b/tests/issues/issue133.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module [issue133.cry] +Loading module Main Using exhaustive testing. Testing... Passed 256 tests. Q.E.D. diff --git a/tests/issues/issue1344.icry.stdout b/tests/issues/issue1344.icry.stdout index 3896b09d4..795267186 100644 --- a/tests/issues/issue1344.icry.stdout +++ b/tests/issues/issue1344.icry.stdout @@ -1,4 +1,4 @@ Loading module Cryptol Loading module Cryptol Loading module A -Loading module [issue1344/issue1344.cry] +Loading module Main diff --git a/tests/issues/issue138.icry.stdout b/tests/issues/issue138.icry.stdout index ca9cd3feb..350488419 100644 --- a/tests/issues/issue138.icry.stdout +++ b/tests/issues/issue138.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module [issue138.cry] +Loading module Main [0xf, 0xe, 0xd, 0xc, 0xb, 0xa, 0x9, 0x8, 0x7, 0x6, 0x5, 0x4, 0x3, 0x2, 0x1, 0x0] [0xf, 0xe, 0xd, 0xc, 0xb, 0xa, 0x9, 0x8, 0x7, 0x6, 0x5, 0x4, 0x3, diff --git a/tests/issues/issue141.icry.stdout b/tests/issues/issue141.icry.stdout index bb4c8b1cc..57a1d7a1c 100644 --- a/tests/issues/issue141.icry.stdout +++ b/tests/issues/issue141.icry.stdout @@ -1,3 +1,3 @@ Loading module Cryptol Loading module Cryptol -Loading module [issue141.cry] +Loading module Main diff --git a/tests/issues/issue1441_a.icry.stdout b/tests/issues/issue1441_a.icry.stdout index e527bc0f1..be86f401d 100644 --- a/tests/issues/issue1441_a.icry.stdout +++ b/tests/issues/issue1441_a.icry.stdout @@ -1,4 +1,4 @@ Loading module Cryptol Loading module Cryptol -Loading module [issue1441_a.rst] +Loading module Main (0x01, 0x02, 0x03, 0x4) diff --git a/tests/issues/issue1441_b.icry.stdout b/tests/issues/issue1441_b.icry.stdout index 7d2bda94e..3c08df297 100644 --- a/tests/issues/issue1441_b.icry.stdout +++ b/tests/issues/issue1441_b.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module [issue1441_b.rst] +Loading module Main [error] at issue1441_b.rst:28:14--28:18: Type mismatch: diff --git a/tests/issues/issue148.icry.stdout b/tests/issues/issue148.icry.stdout index 7cfe17353..7bfc0ec39 100644 --- a/tests/issues/issue148.icry.stdout +++ b/tests/issues/issue148.icry.stdout @@ -1,4 +1,4 @@ Loading module Cryptol Loading module Cryptol -Loading module [issue148.cry] +Loading module Main Satisfiable diff --git a/tests/issues/issue150.icry.stdout b/tests/issues/issue150.icry.stdout index 3b8584c66..e42f8b36e 100644 --- a/tests/issues/issue150.icry.stdout +++ b/tests/issues/issue150.icry.stdout @@ -1,4 +1,4 @@ Loading module Cryptol Loading module Cryptol -Loading module [issue150.cry] +Loading module Main maxSeq' : {n, a} (Cmp a, Literal 0 a) => [n]a -> [1 + n]a diff --git a/tests/issues/issue1502.icry.stdout b/tests/issues/issue1502.icry.stdout index 6db799f34..57a1d7a1c 100644 --- a/tests/issues/issue1502.icry.stdout +++ b/tests/issues/issue1502.icry.stdout @@ -1,3 +1,3 @@ Loading module Cryptol Loading module Cryptol -Loading module [issue1502.md] +Loading module Main diff --git a/tests/issues/issue1503.icry.stdout b/tests/issues/issue1503.icry.stdout index eb41abacc..52cd4132e 100644 --- a/tests/issues/issue1503.icry.stdout +++ b/tests/issues/issue1503.icry.stdout @@ -1,4 +1,4 @@ Loading module Cryptol Loading module Cryptol -Loading module [issue1503.cry] +Loading module Main Q.E.D. diff --git a/tests/issues/issue158.icry.stdout b/tests/issues/issue158.icry.stdout index 3cb39d216..f97a9078b 100644 --- a/tests/issues/issue158.icry.stdout +++ b/tests/issues/issue158.icry.stdout @@ -1,5 +1,5 @@ Loading module Cryptol Loading module Cryptol -Loading module [issue158.cry] +Loading module Main Q.E.D. Q.E.D. diff --git a/tests/issues/issue160.icry.stdout b/tests/issues/issue160.icry.stdout index 80e4caa27..030a592fd 100644 --- a/tests/issues/issue160.icry.stdout +++ b/tests/issues/issue160.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module [issue160.cry] +Loading module Main :prove thm1 Q.E.D. :prove thm2 diff --git a/tests/issues/issue171.icry.stdout b/tests/issues/issue171.icry.stdout index 589815b3a..a8db72a5b 100644 --- a/tests/issues/issue171.icry.stdout +++ b/tests/issues/issue171.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module [issue171.cry] +Loading module Main :prove b Q.E.D. :prove a diff --git a/tests/issues/issue184.icry.stdout b/tests/issues/issue184.icry.stdout index d7636bfb8..9a5988ad3 100644 --- a/tests/issues/issue184.icry.stdout +++ b/tests/issues/issue184.icry.stdout @@ -1,4 +1,4 @@ Loading module Cryptol Loading module Cryptol -Loading module [issue184.cry] +Loading module Main [0x01, 0x02, 0x03, 0x04, 0xff, 0x00, 0x01, 0x02, 0x03, 0x04] diff --git a/tests/issues/issue185.icry.stdout b/tests/issues/issue185.icry.stdout index 28506ef8c..57a1d7a1c 100644 --- a/tests/issues/issue185.icry.stdout +++ b/tests/issues/issue185.icry.stdout @@ -1,3 +1,3 @@ Loading module Cryptol Loading module Cryptol -Loading module [issue185.cry] +Loading module Main diff --git a/tests/issues/issue198.icry.stdout b/tests/issues/issue198.icry.stdout index 1d6a97ee3..cdd08d402 100644 --- a/tests/issues/issue198.icry.stdout +++ b/tests/issues/issue198.icry.stdout @@ -1,4 +1,4 @@ Loading module Cryptol Loading module Cryptol -Loading module [simon.cry2] +Loading module Main True diff --git a/tests/issues/issue212.icry.stdout b/tests/issues/issue212.icry.stdout index 213b65bc0..57a1d7a1c 100644 --- a/tests/issues/issue212.icry.stdout +++ b/tests/issues/issue212.icry.stdout @@ -1,3 +1,3 @@ Loading module Cryptol Loading module Cryptol -Loading module [issue212.cry] +Loading module Main diff --git a/tests/issues/issue214.icry.stdout b/tests/issues/issue214.icry.stdout index 101180490..57a1d7a1c 100644 --- a/tests/issues/issue214.icry.stdout +++ b/tests/issues/issue214.icry.stdout @@ -1,3 +1,3 @@ Loading module Cryptol Loading module Cryptol -Loading module [issue214.cry] +Loading module Main diff --git a/tests/issues/issue268.icry.stdout b/tests/issues/issue268.icry.stdout index 0c7ead03e..038b29cea 100644 --- a/tests/issues/issue268.icry.stdout +++ b/tests/issues/issue268.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module [issue268.cry] +Loading module Main [(0x00, 0x00), (0x00, 0x00), (0x00, 0x00), (0x00, 0x00), (0x00, 0x00), (0x00, 0x00), (0x00, 0x00), (0x00, 0x00), (0x00, 0x00), (0x00, 0x00)] diff --git a/tests/issues/issue290v2.icry.stdout b/tests/issues/issue290v2.icry.stdout index ae99c618b..831325262 100644 --- a/tests/issues/issue290v2.icry.stdout +++ b/tests/issues/issue290v2.icry.stdout @@ -1,10 +1,10 @@ Loading module Cryptol Loading module Cryptol -Loading module [issue290v2.cry] +Loading module Main [error] at issue290v2.cry:2:1--2:19: Failed to validate user-specified signature. - in the definition of '[issue290v2.cry]::minMax', at issue290v2.cry:2:1--2:7, + in the definition of 'Main::minMax', at issue290v2.cry:2:1--2:7, we need to show that for any type n, a assuming @@ -19,7 +19,7 @@ Loading module [issue290v2.cry] Unsolved constraints: • n`892 == 1 arising from - checking a pattern: type of 1st argument of [issue290v2.cry]::minMax + checking a pattern: type of 1st argument of Main::minMax at issue290v2.cry:2:8--2:11 where n`892 is signature variable 'n' at issue290v2.cry:1:11--1:12 diff --git a/tests/issues/issue304.icry.stdout b/tests/issues/issue304.icry.stdout index 9cc740e48..872d02a06 100644 --- a/tests/issues/issue304.icry.stdout +++ b/tests/issues/issue304.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module [issue304.cry] +Loading module Main x : [64] a : [16] b : [48] diff --git a/tests/issues/issue308.icry.stdout b/tests/issues/issue308.icry.stdout index c28209600..57a1d7a1c 100644 --- a/tests/issues/issue308.icry.stdout +++ b/tests/issues/issue308.icry.stdout @@ -1,3 +1,3 @@ Loading module Cryptol Loading module Cryptol -Loading module [issue308.cry] +Loading module Main diff --git a/tests/issues/issue312.icry.stdout b/tests/issues/issue312.icry.stdout index 3058e4954..57a1d7a1c 100644 --- a/tests/issues/issue312.icry.stdout +++ b/tests/issues/issue312.icry.stdout @@ -1,3 +1,3 @@ Loading module Cryptol Loading module Cryptol -Loading module [issue312.cry] +Loading module Main diff --git a/tests/issues/issue314.icry.stdout b/tests/issues/issue314.icry.stdout index 02465d145..57a1d7a1c 100644 --- a/tests/issues/issue314.icry.stdout +++ b/tests/issues/issue314.icry.stdout @@ -1,3 +1,3 @@ Loading module Cryptol Loading module Cryptol -Loading module [issue314.cry] +Loading module Main diff --git a/tests/issues/issue323.icry.stdout b/tests/issues/issue323.icry.stdout index b1bb53848..876f909d3 100644 --- a/tests/issues/issue323.icry.stdout +++ b/tests/issues/issue323.icry.stdout @@ -1,12 +1,12 @@ Loading module Cryptol Loading module Cryptol -Loading module [issue323.cry] +Loading module Main [error] at issue323.cry:2:1--3:51: Failed to infer the following types: • ?m, type argument 'back' of 'take' at issue323.cry:2:43--2:47 while validating user-specified signature - in the definition of '[issue323.cry]::testme', at issue323.cry:2:1--2:7, + in the definition of 'Main::testme', at issue323.cry:2:1--2:7, we need to show that for any type a the following constraints hold: diff --git a/tests/issues/issue364.icry.stdout b/tests/issues/issue364.icry.stdout index fd4888476..0943154a1 100644 --- a/tests/issues/issue364.icry.stdout +++ b/tests/issues/issue364.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module [issue364.cry] +Loading module Main property x_eval Using exhaustive testing. Testing... Passed 1 tests. Q.E.D. diff --git a/tests/issues/issue368.icry.stdout b/tests/issues/issue368.icry.stdout index 169c4c815..57a1d7a1c 100644 --- a/tests/issues/issue368.icry.stdout +++ b/tests/issues/issue368.icry.stdout @@ -1,3 +1,3 @@ Loading module Cryptol Loading module Cryptol -Loading module [issue368.cry] +Loading module Main diff --git a/tests/issues/issue389.icry.stdout b/tests/issues/issue389.icry.stdout index c4bbe4a29..c5f1087fa 100644 --- a/tests/issues/issue389.icry.stdout +++ b/tests/issues/issue389.icry.stdout @@ -1,5 +1,5 @@ Loading module Cryptol Loading module Cryptol -Loading module [issue389.cry] +Loading module Main 0x61800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008 0x61800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008 diff --git a/tests/issues/issue416.icry.stdout b/tests/issues/issue416.icry.stdout index 27ad24f53..00a6435d9 100644 --- a/tests/issues/issue416.icry.stdout +++ b/tests/issues/issue416.icry.stdout @@ -1,10 +1,10 @@ Loading module Cryptol Loading module Cryptol -Loading module [issue416.cry] +Loading module Main [error] at issue416.cry:2:1--2:16: Failed to validate user-specified signature. - in the definition of '[issue416.cry]::f', at issue416.cry:2:1--2:2, + in the definition of 'Main::f', at issue416.cry:2:1--2:2, we need to show that for any type n assuming @@ -17,7 +17,7 @@ Loading module [issue416.cry] at issue416.cry:2:5--2:16 [error] at issue416.cry:5:1--5:16: Failed to validate user-specified signature. - in the definition of '[issue416.cry]::g', at issue416.cry:5:1--5:2, + in the definition of 'Main::g', at issue416.cry:5:1--5:2, we need to show that for any type n assuming diff --git a/tests/issues/issue494.icry.stdout b/tests/issues/issue494.icry.stdout index dcb74809a..72698e616 100644 --- a/tests/issues/issue494.icry.stdout +++ b/tests/issues/issue494.icry.stdout @@ -1,4 +1,4 @@ Loading module Cryptol Loading module Cryptol -Loading module [issue494.cry] +Loading module Main gt_words' : {n, m, a} (Cmp a, fin (min (1 + n) (1 + m))) => [n]a -> [m]a -> Bit diff --git a/tests/issues/issue513.icry.stdout b/tests/issues/issue513.icry.stdout index ef9364fc3..ad1a6057a 100644 --- a/tests/issues/issue513.icry.stdout +++ b/tests/issues/issue513.icry.stdout @@ -1,25 +1,25 @@ Loading module Cryptol Loading module Cryptol -Loading module [issue513.cry] +Loading module Main [warning] at issue513.cry:1:8--1:15: Assuming a to have a numeric type -module [issue513.cry] +module Main /* Recursive */ -[issue513.cry]::test : {a} [1 + a] -[issue513.cry]::test = +Main::test : {a} [1 + a] +Main::test = \{a} -> - [issue513.cry]::$mono + Main::$mono where /* Recursive */ - [issue513.cry]::$mono : [1 + a] - [issue513.cry]::$mono = + Main::$mono : [1 + a] + Main::$mono = (Cryptol::#) 1 a Bit <> [Cryptol::False] [y | i <- Cryptol::zero [a] <> - | y <- [issue513.cry]::$mono] + | y <- Main::$mono] -[issue513.cry]::test +Main::test test : {a} [1 + a] -[issue513.cry]::test 8 +Main::test 8 0x000 diff --git a/tests/issues/issue581.icry.stdout b/tests/issues/issue581.icry.stdout index 3cff9b915..57a1d7a1c 100644 --- a/tests/issues/issue581.icry.stdout +++ b/tests/issues/issue581.icry.stdout @@ -1,3 +1,3 @@ Loading module Cryptol Loading module Cryptol -Loading module [issue581.cry] +Loading module Main diff --git a/tests/issues/issue582.icry.stdout b/tests/issues/issue582.icry.stdout index 3bed785c9..07de82fc5 100644 --- a/tests/issues/issue582.icry.stdout +++ b/tests/issues/issue582.icry.stdout @@ -30,11 +30,11 @@ Loading module Cryptol use of partial type function (%^) at issue582.icry:6:1--6:16 Loading module Cryptol -Loading module [issue582.cry] +Loading module Main [error] at issue582.cry:2:1--2:11: Failed to validate user-specified signature. - in the definition of '[issue582.cry]::foo', at issue582.cry:2:1--2:4, + in the definition of 'Main::foo', at issue582.cry:2:1--2:4, we need to show that for any type i, j the following constraints hold: @@ -48,7 +48,7 @@ Loading module [issue582.cry] at issue582.cry:1:7--1:21 [error] at issue582.cry:5:1--5:11: Failed to validate user-specified signature. - in the definition of '[issue582.cry]::bar', at issue582.cry:5:1--5:4, + in the definition of 'Main::bar', at issue582.cry:5:1--5:4, we need to show that for any type i, j the following constraints hold: diff --git a/tests/issues/issue614.icry.stdout b/tests/issues/issue614.icry.stdout index 7459112aa..5c55abeca 100644 --- a/tests/issues/issue614.icry.stdout +++ b/tests/issues/issue614.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module [issue614.cry] +Loading module Main [error] at issue614.cry:1:18--1:20 and issue614.cry:1:31--1:33 The fixities of diff --git a/tests/issues/issue640.icry.stdout b/tests/issues/issue640.icry.stdout index c5870b46c..6b890958c 100644 --- a/tests/issues/issue640.icry.stdout +++ b/tests/issues/issue640.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module [issue640.cry] +Loading module Main 0x0 0x0 [0x00, 0x00] diff --git a/tests/issues/issue662.icry.stdout b/tests/issues/issue662.icry.stdout index 04669de91..3f0641eaa 100644 --- a/tests/issues/issue662.icry.stdout +++ b/tests/issues/issue662.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module [issue662.cry] +Loading module Main property divRoundsDown Using random testing. Testing... Passed 1000 tests. property divEuclidean Using random testing. diff --git a/tests/issues/issue670.icry.stdout b/tests/issues/issue670.icry.stdout index 44a8c2b91..36ea81ffe 100644 --- a/tests/issues/issue670.icry.stdout +++ b/tests/issues/issue670.icry.stdout @@ -1,5 +1,5 @@ Loading module Cryptol Loading module Cryptol -Loading module [issue670.cry] +Loading module Main g : [6 +++ 2 +++ 1] h : [6 +++ (2 +++ 1)] diff --git a/tests/issues/issue68.icry.stdout b/tests/issues/issue68.icry.stdout index a95d40171..463f5a0cd 100644 --- a/tests/issues/issue68.icry.stdout +++ b/tests/issues/issue68.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module [issue68.cry] +Loading module Main Hi! 0x00 Hi! 0x01 Hi! 0x02 diff --git a/tests/issues/issue723.icry.stdout b/tests/issues/issue723.icry.stdout index e0a9ec4fa..86b922758 100644 --- a/tests/issues/issue723.icry.stdout +++ b/tests/issues/issue723.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module [issue723.cry] +Loading module Main [error] at issue723.cry:7:5--7:19: Failed to validate user-specified signature. diff --git a/tests/issues/issue731.cry b/tests/issues/issue731.cry index 37d6c3f64..726a6605b 100644 --- a/tests/issues/issue731.cry +++ b/tests/issues/issue731.cry @@ -1,5 +1,3 @@ -module issue731 where - type constraint T n = (fin n, n >= 1) type constraint Both p q = (p, q) diff --git a/tests/issues/issue731.icry b/tests/issues/issue731.icry index 5a2d57d7e..241ac1980 100644 --- a/tests/issues/issue731.icry +++ b/tests/issues/issue731.icry @@ -1,2 +1,2 @@ :l issue731.cry -:browse issue731 +:browse Main diff --git a/tests/issues/issue731.icry.stdout b/tests/issues/issue731.icry.stdout index 177c7159a..d97ed83b8 100644 --- a/tests/issues/issue731.icry.stdout +++ b/tests/issues/issue731.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module issue731 +Loading module Main Constraint Synonyms =================== diff --git a/tests/issues/issue734.icry.stdout b/tests/issues/issue734.icry.stdout index 94bc8bd2c..e47728b24 100644 --- a/tests/issues/issue734.icry.stdout +++ b/tests/issues/issue734.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module [issue734.cry] +Loading module Main 0x156ad5 0x100 0xff diff --git a/tests/issues/issue78.icry.stdout b/tests/issues/issue78.icry.stdout index f071d46d0..bb8d1ac40 100644 --- a/tests/issues/issue78.icry.stdout +++ b/tests/issues/issue78.icry.stdout @@ -1,4 +1,4 @@ Loading module Cryptol Loading module Cryptol -Loading module [issue78.cry] +Loading module Main unique : {a, b} (fin a, fin b, a >= 1) => [a][b] -> Bit diff --git a/tests/issues/issue826.icry.stdout b/tests/issues/issue826.icry.stdout index a31c760ae..9623da6b3 100644 --- a/tests/issues/issue826.icry.stdout +++ b/tests/issues/issue826.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module [issue826.cry] +Loading module Main [error] at issue826.cry:3:6--3:11: Incorrect type form. diff --git a/tests/issues/issue845.icry.stdout b/tests/issues/issue845.icry.stdout index fd5eff82a..4145e2858 100644 --- a/tests/issues/issue845.icry.stdout +++ b/tests/issues/issue845.icry.stdout @@ -1,10 +1,10 @@ Loading module Cryptol Loading module Cryptol -Loading module [issue845.cry] +Loading module Main [error] at issue845.cry:2:1--2:37: Failed to validate user-specified signature. - in the definition of '[issue845.cry]::rfrac', at issue845.cry:2:1--2:6, + in the definition of 'Main::rfrac', at issue845.cry:2:1--2:6, we need to show that for any type m, n the following constraints hold: diff --git a/tests/issues/issue850.icry.stdout b/tests/issues/issue850.icry.stdout index f3199d0ad..a630df8cc 100644 --- a/tests/issues/issue850.icry.stdout +++ b/tests/issues/issue850.icry.stdout @@ -1,4 +1,4 @@ Loading module Cryptol Loading module Cryptol -Loading module [issue850.cry] +Loading module Main [(ratio 0 1), (ratio 3 1)] diff --git a/tests/issues/issue851.icry.stdout b/tests/issues/issue851.icry.stdout index c002663c4..c4ab0ff1c 100644 --- a/tests/issues/issue851.icry.stdout +++ b/tests/issues/issue851.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module [issue851.cry] +Loading module Main Using exhaustive testing. Testing... Counterexample problem 0x01 = False diff --git a/tests/issues/issue852.icry.stdout b/tests/issues/issue852.icry.stdout index 99235f3c8..57a1d7a1c 100644 --- a/tests/issues/issue852.icry.stdout +++ b/tests/issues/issue852.icry.stdout @@ -1,3 +1,3 @@ Loading module Cryptol Loading module Cryptol -Loading module [issue852.md] +Loading module Main diff --git a/tests/issues/issue877.icry.stdout b/tests/issues/issue877.icry.stdout index c5ea77dcf..d534ea752 100644 --- a/tests/issues/issue877.icry.stdout +++ b/tests/issues/issue877.icry.stdout @@ -12,7 +12,7 @@ Showing a specific instance of polymorphic result: * Using 'Bit' for type of sequence member [] Loading module Cryptol -Loading module [issue877.cry] +Loading module Main a : {a} [0]a Showing a specific instance of polymorphic result: * Using 'Integer' for type of sequence member diff --git a/tests/issues/issue894.icry.stdout b/tests/issues/issue894.icry.stdout index 047a6e774..9d8d8cd73 100644 --- a/tests/issues/issue894.icry.stdout +++ b/tests/issues/issue894.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module [issue894.cry] +Loading module Main [warning] at issue894.cry:1:10--1:11 Unused name: n [warning] at issue894.cry:1:6--1:11: diff --git a/tests/issues/issue962.icry.stdout b/tests/issues/issue962.icry.stdout index ca38180db..b8676f3e7 100644 --- a/tests/issues/issue962.icry.stdout +++ b/tests/issues/issue962.icry.stdout @@ -12,11 +12,11 @@ Parse error at issue962.icry:3:1--3:11 Explicit type applications can only be applied to named values. Unexpected: number`{3} Loading module Cryptol -Loading module [issue962a.cry] +Loading module Main i : {a} (fin a) => [a] -> [a] j : {a} (fin a) => [a]{fld : Integer} -> [a]Integer Loading module Cryptol -Loading module [issue962b.cry] +Loading module Main [error] at issue962b.cry:32:16--32:25: Unexpected bare type application. diff --git a/tests/issues/trac133.icry.stdout b/tests/issues/trac133.icry.stdout index 813f7cbc5..2a5274351 100644 --- a/tests/issues/trac133.icry.stdout +++ b/tests/issues/trac133.icry.stdout @@ -1,5 +1,5 @@ Loading module Cryptol Loading module Cryptol -Loading module [trac133.cry] +Loading module Main example1 : {a} (a >= 1, 2 >= a) => [16 * a][8] -> [16][8] example2 : {a} (a >= 1, 2 >= a) => [16 * a][8] -> [16][8] diff --git a/tests/issues/trac289.icry.stdout b/tests/issues/trac289.icry.stdout index 33e3574d4..c491ee9a8 100644 --- a/tests/issues/trac289.icry.stdout +++ b/tests/issues/trac289.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module [trac289.cry] +Loading module Main Q.E.D. Counterexample Q.E.D. diff --git a/tests/modsys/T1330.icry.stdout b/tests/modsys/T1330.icry.stdout index 64542d3b8..8da6c348b 100644 --- a/tests/modsys/T1330.icry.stdout +++ b/tests/modsys/T1330.icry.stdout @@ -1,4 +1,4 @@ Loading module Cryptol Loading module Cryptol Loading module modA -Loading module [T1330/main.cry] +Loading module Main diff --git a/tests/modsys/functors/T001.icry.stdout b/tests/modsys/functors/T001.icry.stdout index 62cdeec2c..9c9423fb4 100644 --- a/tests/modsys/functors/T001.icry.stdout +++ b/tests/modsys/functors/T001.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module [T001.cry] +Loading module Main [error] at T001.cry:16:11--16:12: • Unsolvable constraint: diff --git a/tests/modsys/functors/T002.icry.stdout b/tests/modsys/functors/T002.icry.stdout index e8a41cb5d..aa0e86e34 100644 --- a/tests/modsys/functors/T002.icry.stdout +++ b/tests/modsys/functors/T002.icry.stdout @@ -1,4 +1,4 @@ Loading module Cryptol Loading module Cryptol -Loading module [T002.cry] +Loading module Main 0x03 diff --git a/tests/modsys/functors/T003.icry.stdout b/tests/modsys/functors/T003.icry.stdout index a6a86d3da..3dbf46654 100644 --- a/tests/modsys/functors/T003.icry.stdout +++ b/tests/modsys/functors/T003.icry.stdout @@ -1,4 +1,4 @@ Loading module Cryptol Loading module Cryptol -Loading module [T003.cry] +Loading module Main 0x2b diff --git a/tests/modsys/functors/T004.icry.stdout b/tests/modsys/functors/T004.icry.stdout index 5128f7a9f..9685a2a14 100644 --- a/tests/modsys/functors/T004.icry.stdout +++ b/tests/modsys/functors/T004.icry.stdout @@ -1,4 +1,4 @@ Loading module Cryptol Loading module Cryptol -Loading module [T004.cry] +Loading module Main 0x06 diff --git a/tests/modsys/functors/T005.icry.stdout b/tests/modsys/functors/T005.icry.stdout index 35a415325..e2fabfbce 100644 --- a/tests/modsys/functors/T005.icry.stdout +++ b/tests/modsys/functors/T005.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module [T005.cry] +Loading module Main [error] at T005.cry:28:11--28:12: • Unsolvable constraint: diff --git a/tests/modsys/functors/T006.icry.stdout b/tests/modsys/functors/T006.icry.stdout index 597fba632..18a124149 100644 --- a/tests/modsys/functors/T006.icry.stdout +++ b/tests/modsys/functors/T006.icry.stdout @@ -1,5 +1,5 @@ Loading module Cryptol Loading module Cryptol -Loading module [T006.cry] +Loading module Main 0x0f 0x12 diff --git a/tests/modsys/functors/T007.icry.stdout b/tests/modsys/functors/T007.icry.stdout index 6f035fa57..43c470464 100644 --- a/tests/modsys/functors/T007.icry.stdout +++ b/tests/modsys/functors/T007.icry.stdout @@ -1,4 +1,4 @@ Loading module Cryptol Loading module Cryptol -Loading module [T007.cry] +Loading module Main 0x0d diff --git a/tests/modsys/functors/T008.icry.stdout b/tests/modsys/functors/T008.icry.stdout index 2ea3df745..74d3f7bf9 100644 --- a/tests/modsys/functors/T008.icry.stdout +++ b/tests/modsys/functors/T008.icry.stdout @@ -1,4 +1,4 @@ Loading module Cryptol Loading module Cryptol -Loading module [T008.cry] +Loading module Main 0x2 diff --git a/tests/modsys/functors/T009.icry.stdout b/tests/modsys/functors/T009.icry.stdout index 04dddc577..8e124ba5f 100644 --- a/tests/modsys/functors/T009.icry.stdout +++ b/tests/modsys/functors/T009.icry.stdout @@ -1,4 +1,4 @@ Loading module Cryptol Loading module Cryptol Loading module T009_S -Loading module [T009.cry] +Loading module Main diff --git a/tests/modsys/functors/T011.icry.stdout b/tests/modsys/functors/T011.icry.stdout index 12960ca8f..c9603eca1 100644 --- a/tests/modsys/functors/T011.icry.stdout +++ b/tests/modsys/functors/T011.icry.stdout @@ -1,4 +1,4 @@ Loading module Cryptol Loading module Cryptol -Loading module [T011.cry] +Loading module Main 0x38 diff --git a/tests/modsys/functors/T012.icry.stdout b/tests/modsys/functors/T012.icry.stdout index 0989253b2..11c5b732c 100644 --- a/tests/modsys/functors/T012.icry.stdout +++ b/tests/modsys/functors/T012.icry.stdout @@ -1,5 +1,5 @@ Loading module Cryptol Loading module Cryptol Loading module T012_M -Loading module [T012.cry] +Loading module Main 0x38 diff --git a/tests/modsys/functors/T013.icry.stdout b/tests/modsys/functors/T013.icry.stdout index 52762075a..bd62e51ec 100644 --- a/tests/modsys/functors/T013.icry.stdout +++ b/tests/modsys/functors/T013.icry.stdout @@ -1,7 +1,7 @@ Loading module Cryptol Loading module Cryptol -Loading module [T013.cry] +Loading module Main [error] at T013.cry:6:30--6:31 • Expected an interface - • `submodule [T013.cry]::A` is a module + • `submodule Main::A` is a module diff --git a/tests/modsys/functors/T014.icry.stdout b/tests/modsys/functors/T014.icry.stdout index 7d44bfda2..8f6183247 100644 --- a/tests/modsys/functors/T014.icry.stdout +++ b/tests/modsys/functors/T014.icry.stdout @@ -1,7 +1,7 @@ Loading module Cryptol Loading module Cryptol -Loading module [T014.cry] +Loading module Main [error] at T014.cry:5:1--5:19 • Expected a module - • `submodule [T014.cry]::A` is an interface + • `submodule Main::A` is an interface diff --git a/tests/modsys/functors/T015.icry.stdout b/tests/modsys/functors/T015.icry.stdout index cc4817b1b..953adc64d 100644 --- a/tests/modsys/functors/T015.icry.stdout +++ b/tests/modsys/functors/T015.icry.stdout @@ -1,4 +1,4 @@ Loading module Cryptol Loading module Cryptol Loading interface module T015_S -Loading module [T015.cry] +Loading module Main diff --git a/tests/modsys/functors/T016.icry.stdout b/tests/modsys/functors/T016.icry.stdout index 335a179c3..b8bfd491e 100644 --- a/tests/modsys/functors/T016.icry.stdout +++ b/tests/modsys/functors/T016.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module [T016.cry] +Loading module Main [error] at T016.cry:14:39--14:40: Functor argument does not define value parameter 'x' diff --git a/tests/modsys/functors/T021.icry.stdout b/tests/modsys/functors/T021.icry.stdout index 80e12f29a..aa0e86e34 100644 --- a/tests/modsys/functors/T021.icry.stdout +++ b/tests/modsys/functors/T021.icry.stdout @@ -1,4 +1,4 @@ Loading module Cryptol Loading module Cryptol -Loading module [T021.cry] +Loading module Main 0x03 diff --git a/tests/modsys/functors/T022.icry.stdout b/tests/modsys/functors/T022.icry.stdout index bbb2e8380..a2244dbbd 100644 --- a/tests/modsys/functors/T022.icry.stdout +++ b/tests/modsys/functors/T022.icry.stdout @@ -1,4 +1,4 @@ Loading module Cryptol Loading module Cryptol -Loading module [T022.cry] +Loading module Main 0x04 diff --git a/tests/modsys/functors/T025.icry.stdout b/tests/modsys/functors/T025.icry.stdout index 3a8444ef3..cd5beea70 100644 --- a/tests/modsys/functors/T025.icry.stdout +++ b/tests/modsys/functors/T025.icry.stdout @@ -1,4 +1,4 @@ Loading module Cryptol Loading module Cryptol -Loading module [T025.cry] +Loading module Main 0x0b diff --git a/tests/modsys/functors/T026.icry.stdout b/tests/modsys/functors/T026.icry.stdout index b034804d9..cd5beea70 100644 --- a/tests/modsys/functors/T026.icry.stdout +++ b/tests/modsys/functors/T026.icry.stdout @@ -1,4 +1,4 @@ Loading module Cryptol Loading module Cryptol -Loading module [T026.cry] +Loading module Main 0x0b diff --git a/tests/modsys/functors/T027.icry.stdout b/tests/modsys/functors/T027.icry.stdout index 3136127cd..43c470464 100644 --- a/tests/modsys/functors/T027.icry.stdout +++ b/tests/modsys/functors/T027.icry.stdout @@ -1,4 +1,4 @@ Loading module Cryptol Loading module Cryptol -Loading module [T027.cry] +Loading module Main 0x0d diff --git a/tests/modsys/functors/T028.icry.stdout b/tests/modsys/functors/T028.icry.stdout index 05f7176e8..cd5beea70 100644 --- a/tests/modsys/functors/T028.icry.stdout +++ b/tests/modsys/functors/T028.icry.stdout @@ -1,4 +1,4 @@ Loading module Cryptol Loading module Cryptol -Loading module [T028.cry] +Loading module Main 0x0b diff --git a/tests/modsys/functors/T029.icry.stdout b/tests/modsys/functors/T029.icry.stdout index 477f059d1..76ed2acfb 100644 --- a/tests/modsys/functors/T029.icry.stdout +++ b/tests/modsys/functors/T029.icry.stdout @@ -5,5 +5,5 @@ Loading module Cryptol {a, n} (fin n) => n / 2 == n - n /^ 2 {n, a, b} n == min n n {n} (n >= 1, fin n) => (fin n, n >= 1) -Loading module [T029.cry] +Loading module Main () diff --git a/tests/modsys/functors/T031.icry.stdout b/tests/modsys/functors/T031.icry.stdout index 6a6db9a66..f10397c0e 100644 --- a/tests/modsys/functors/T031.icry.stdout +++ b/tests/modsys/functors/T031.icry.stdout @@ -2,5 +2,5 @@ Loading module Cryptol Loading module Cryptol Loading interface module T030_I Loading module T030 -Loading module [T031.cry] +Loading module Main 0x0b diff --git a/tests/modsys/functors/T033.icry.stdout b/tests/modsys/functors/T033.icry.stdout index 9b5e2c72a..57a1d7a1c 100644 --- a/tests/modsys/functors/T033.icry.stdout +++ b/tests/modsys/functors/T033.icry.stdout @@ -1,3 +1,3 @@ Loading module Cryptol Loading module Cryptol -Loading module [T033.cry] +Loading module Main diff --git a/tests/modsys/functors/T035.icry.stdout b/tests/modsys/functors/T035.icry.stdout index 8c4921609..1c73a1303 100644 --- a/tests/modsys/functors/T035.icry.stdout +++ b/tests/modsys/functors/T035.icry.stdout @@ -1,15 +1,15 @@ Loading module Cryptol Loading module Cryptol -Loading module [T035.cry] +Loading module Main [warning] at T035.cry:12:5--12:6 This binding for `x` shadows the existing binding at T035.cry:22:1--22:2 [error] at T035.cry:22:11--22:15: Type mismatch: - Expected type: [T035.cry]::M::X ?m - Inferred type: [T035.cry]::N::X 0 + Expected type: Main::M::X ?m + Inferred type: Main::N::X 0 Context: _ -> ERROR When checking function call where - ?m is type argument 'n' of '[T035.cry]::M::f' at T035.cry:22:5--22:9 + ?m is type argument 'n' of 'Main::M::f' at T035.cry:22:5--22:9 diff --git a/tests/modsys/functors/T040.icry.stdout b/tests/modsys/functors/T040.icry.stdout index 644ded6d4..ce0781a5f 100644 --- a/tests/modsys/functors/T040.icry.stdout +++ b/tests/modsys/functors/T040.icry.stdout @@ -1,4 +1,4 @@ Loading module Cryptol Loading module Cryptol -Loading module [T040.cry] +Loading module Main () diff --git a/tests/modsys/nested/T16.icry.stdout b/tests/modsys/nested/T16.icry.stdout index d6206054a..938fa713c 100644 --- a/tests/modsys/nested/T16.icry.stdout +++ b/tests/modsys/nested/T16.icry.stdout @@ -1,7 +1,7 @@ Loading module Cryptol Loading module Cryptol Loading module T16_M -Loading module [T16.cry] +Loading module Main [error] at T16.cry:2:1--2:19 Module not in scope: A diff --git a/tests/modsys/nested/T7.icry.stdout b/tests/modsys/nested/T7.icry.stdout index fa7362a41..57a1d7a1c 100644 --- a/tests/modsys/nested/T7.icry.stdout +++ b/tests/modsys/nested/T7.icry.stdout @@ -1,3 +1,3 @@ Loading module Cryptol Loading module Cryptol -Loading module [T7.cry] +Loading module Main diff --git a/tests/parser/T437.icry.stdout b/tests/parser/T437.icry.stdout index b9a4170e7..57a1d7a1c 100644 --- a/tests/parser/T437.icry.stdout +++ b/tests/parser/T437.icry.stdout @@ -1,3 +1,3 @@ Loading module Cryptol Loading module Cryptol -Loading module [T437.cry] +Loading module Main diff --git a/tests/parser/docs.icry.stdout b/tests/parser/docs.icry.stdout index 1ab63f53c..1c3dd5e63 100644 --- a/tests/parser/docs.icry.stdout +++ b/tests/parser/docs.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module [docs.cry] +Loading module Main test1 : Bit diff --git a/tests/parser/infix-1.icry.stdout b/tests/parser/infix-1.icry.stdout index d7a98663c..5f8376c40 100644 --- a/tests/parser/infix-1.icry.stdout +++ b/tests/parser/infix-1.icry.stdout @@ -1,4 +1,4 @@ Loading module Cryptol Loading module Cryptol -Loading module [infix-1.cry] +Loading module Main 0x07 diff --git a/tests/parser/infix-2.icry.stdout b/tests/parser/infix-2.icry.stdout index d487e3271..ebe8dbf07 100644 --- a/tests/parser/infix-2.icry.stdout +++ b/tests/parser/infix-2.icry.stdout @@ -1,5 +1,5 @@ Loading module Cryptol Loading module Cryptol -Loading module [infix-2.cry] +Loading module Main True True diff --git a/tests/parser/infix-3.icry.stdout b/tests/parser/infix-3.icry.stdout index 384a65602..976dd8bac 100644 --- a/tests/parser/infix-3.icry.stdout +++ b/tests/parser/infix-3.icry.stdout @@ -1,4 +1,4 @@ Loading module Cryptol Loading module Cryptol -Loading module [infix-3.cry] +Loading module Main (/\) : Bool -> Bool -> Bool diff --git a/tests/parser/unary-2.icry.stdout b/tests/parser/unary-2.icry.stdout index 9ae38d6be..b38d50fc5 100644 --- a/tests/parser/unary-2.icry.stdout +++ b/tests/parser/unary-2.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module [unary-2.cry] +Loading module Main Showing a specific instance of polymorphic result: * Using '[2]' for type argument 'a' of 'Cryptol::min' True diff --git a/tests/parser/unary.icry.stdout b/tests/parser/unary.icry.stdout index 597be2466..ebe8dbf07 100644 --- a/tests/parser/unary.icry.stdout +++ b/tests/parser/unary.icry.stdout @@ -1,5 +1,5 @@ Loading module Cryptol Loading module Cryptol -Loading module [unary.cry] +Loading module Main True True diff --git a/tests/regression/EvenMansour.icry.stdout b/tests/regression/EvenMansour.icry.stdout index 34c0c4c0c..06cd82dc1 100644 --- a/tests/regression/EvenMansour.icry.stdout +++ b/tests/regression/EvenMansour.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module [../../examples/contrib/EvenMansour.cry] +Loading module Main Using exhaustive testing. Testing... Passed 1 tests. Q.E.D. diff --git a/tests/regression/allsat.icry.stdout b/tests/regression/allsat.icry.stdout index fb621c2cf..12c5a4c0a 100644 --- a/tests/regression/allsat.icry.stdout +++ b/tests/regression/allsat.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module [allsat.cry] +Loading module Main Satisfiable Models found: 3375 Satisfiable diff --git a/tests/regression/bitshift.icry.stdout b/tests/regression/bitshift.icry.stdout index 4a0b535d4..9cc082977 100644 --- a/tests/regression/bitshift.icry.stdout +++ b/tests/regression/bitshift.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module [bitshift.cry] +Loading module Main Using exhaustive testing. Testing... Passed 32 tests. Q.E.D. diff --git a/tests/regression/bvdiv.icry.stdout b/tests/regression/bvdiv.icry.stdout index 6564083d0..ae5c6a352 100644 --- a/tests/regression/bvdiv.icry.stdout +++ b/tests/regression/bvdiv.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module [bvdiv.cry] +Loading module Main property d1 Using exhaustive testing. Testing... Passed 65536 tests. Q.E.D. diff --git a/tests/regression/check01.icry.stdout b/tests/regression/check01.icry.stdout index c436f18a0..a1379870f 100644 --- a/tests/regression/check01.icry.stdout +++ b/tests/regression/check01.icry.stdout @@ -1,5 +1,5 @@ Loading module Cryptol Loading module Cryptol -Loading module [check01.cry] +Loading module Main [0x00000007, 0x00000014] True diff --git a/tests/regression/check02.icry.stdout b/tests/regression/check02.icry.stdout index c1cead4aa..a53b2d018 100644 --- a/tests/regression/check02.icry.stdout +++ b/tests/regression/check02.icry.stdout @@ -1,7 +1,7 @@ Loading module Cryptol Loading module Cryptol -Loading module [check02.cry] +Loading module Main Showing a specific instance of polymorphic result: - * Using 'Integer' for 1st type argument of '[check02.cry]::ones' + * Using 'Integer' for 1st type argument of 'Main::ones' [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1] True diff --git a/tests/regression/check03.icry.stdout b/tests/regression/check03.icry.stdout index 0901c1300..c980e9393 100644 --- a/tests/regression/check03.icry.stdout +++ b/tests/regression/check03.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module [check03.cry] +Loading module Main [0x00000000, 0x00000001, 0x00000002, 0x00000003, 0x00000004, 0x00000005, 0x00000006, 0x00000007, 0x00000008, 0x00000009, 0x0000000a] diff --git a/tests/regression/check04.icry.stdout b/tests/regression/check04.icry.stdout index 06de9ac9e..4b045b572 100644 --- a/tests/regression/check04.icry.stdout +++ b/tests/regression/check04.icry.stdout @@ -1,7 +1,7 @@ Loading module Cryptol Loading module Cryptol -Loading module [check04.cry] +Loading module Main Showing a specific instance of polymorphic result: - * Using 'Integer' for 1st type argument of '[check04.cry]::onetwos' + * Using 'Integer' for 1st type argument of 'Main::onetwos' [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1] True diff --git a/tests/regression/check05.icry.stdout b/tests/regression/check05.icry.stdout index d18965ea2..e63615187 100644 --- a/tests/regression/check05.icry.stdout +++ b/tests/regression/check05.icry.stdout @@ -1,7 +1,7 @@ Loading module Cryptol Loading module Cryptol -Loading module [check05.cry] +Loading module Main Showing a specific instance of polymorphic result: - * Using 'Integer' for 1st type argument of '[check05.cry]::twoones' + * Using 'Integer' for 1st type argument of 'Main::twoones' [2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2] True diff --git a/tests/regression/check06.icry.stdout b/tests/regression/check06.icry.stdout index 16bc6ae98..9190ed75d 100644 --- a/tests/regression/check06.icry.stdout +++ b/tests/regression/check06.icry.stdout @@ -1,8 +1,8 @@ Loading module Cryptol Loading module Cryptol -Loading module [check06.cry] +Loading module Main Showing a specific instance of polymorphic result: - * Using 'Integer' for 1st type argument of '[check06.cry]::onesytwosy' + * Using 'Integer' for 1st type argument of 'Main::onesytwosy' [[1, 2], [2, 1], [1, 2], [2, 1], [1, 2], [2, 1], [1, 2], [2, 1], [1, 2], [2, 1], [1, 2]] True diff --git a/tests/regression/check07.icry.stdout b/tests/regression/check07.icry.stdout index 79ce158b2..51424538a 100644 --- a/tests/regression/check07.icry.stdout +++ b/tests/regression/check07.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module [check07.cry] +Loading module Main [0b00010010001101000101011001111000, 0b00100100011010001010110011110000, 0b01001000110100010101100111100000, diff --git a/tests/regression/check08.icry.stdout b/tests/regression/check08.icry.stdout index 54a7150b7..c125cd307 100644 --- a/tests/regression/check08.icry.stdout +++ b/tests/regression/check08.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module [check08.cry] +Loading module Main [0x00000001, 0x00000002, 0x00000005, 0x0000000c, 0x0000001b] True Q.E.D. diff --git a/tests/regression/check09.icry.stdout b/tests/regression/check09.icry.stdout index dfd40b24a..09f1f8ef4 100644 --- a/tests/regression/check09.icry.stdout +++ b/tests/regression/check09.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module [check09.cry] +Loading module Main [warning] at check09.cry:21:5--21:10 This binding for `initS` shadows the existing binding at check09.cry:3:1--3:6 diff --git a/tests/regression/check10.icry.stdout b/tests/regression/check10.icry.stdout index 082099987..937d75544 100644 --- a/tests/regression/check10.icry.stdout +++ b/tests/regression/check10.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module [check10.cry] +Loading module Main 0x00 0x00 True diff --git a/tests/regression/check11.icry.stdout b/tests/regression/check11.icry.stdout index 9c58588eb..cdd08d402 100644 --- a/tests/regression/check11.icry.stdout +++ b/tests/regression/check11.icry.stdout @@ -1,4 +1,4 @@ Loading module Cryptol Loading module Cryptol -Loading module [check11.cry] +Loading module Main True diff --git a/tests/regression/check12.icry.stdout b/tests/regression/check12.icry.stdout index a060b0fef..bea7290e7 100644 --- a/tests/regression/check12.icry.stdout +++ b/tests/regression/check12.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module [check12.cry] +Loading module Main [0x00000000, 0x00000001, 0x00000003, 0x00000006, 0x0000000a, 0x0000000f, 0x00000015, 0x0000001c, 0x00000024, 0x0000002d] True diff --git a/tests/regression/check13.icry.stdout b/tests/regression/check13.icry.stdout index 0e7ba6046..6773e5d93 100644 --- a/tests/regression/check13.icry.stdout +++ b/tests/regression/check13.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module [check13.cry] +Loading module Main 0x96 0x96 True diff --git a/tests/regression/check14.icry.stdout b/tests/regression/check14.icry.stdout index fd0096bba..edaacd6ff 100644 --- a/tests/regression/check14.icry.stdout +++ b/tests/regression/check14.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module [check14.cry] +Loading module Main Showing a specific instance of polymorphic result: * Using 'Integer' for type of sequence member [[3, 2, 1, 0], [7, 6, 5, 4]] diff --git a/tests/regression/check15.icry.stdout b/tests/regression/check15.icry.stdout index cb55272b0..21dbbdfa1 100644 --- a/tests/regression/check15.icry.stdout +++ b/tests/regression/check15.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module [check15.cry] +Loading module Main False 0xabcd True diff --git a/tests/regression/check16-tab.icry.stdout b/tests/regression/check16-tab.icry.stdout index b12cbb209..cdd08d402 100644 --- a/tests/regression/check16-tab.icry.stdout +++ b/tests/regression/check16-tab.icry.stdout @@ -1,4 +1,4 @@ Loading module Cryptol Loading module Cryptol -Loading module [check16-tab.cry] +Loading module Main True diff --git a/tests/regression/check16.icry.stdout b/tests/regression/check16.icry.stdout index f319d070c..cdd08d402 100644 --- a/tests/regression/check16.icry.stdout +++ b/tests/regression/check16.icry.stdout @@ -1,4 +1,4 @@ Loading module Cryptol Loading module Cryptol -Loading module [check16.cry] +Loading module Main True diff --git a/tests/regression/check17.icry.stdout b/tests/regression/check17.icry.stdout index 51d1baa1a..cdd08d402 100644 --- a/tests/regression/check17.icry.stdout +++ b/tests/regression/check17.icry.stdout @@ -1,4 +1,4 @@ Loading module Cryptol Loading module Cryptol -Loading module [check17.cry] +Loading module Main True diff --git a/tests/regression/check18.icry.stdout b/tests/regression/check18.icry.stdout index 407543182..cdd08d402 100644 --- a/tests/regression/check18.icry.stdout +++ b/tests/regression/check18.icry.stdout @@ -1,4 +1,4 @@ Loading module Cryptol Loading module Cryptol -Loading module [check18.cry] +Loading module Main True diff --git a/tests/regression/check19.icry.stdout b/tests/regression/check19.icry.stdout index 36ce7698e..5ffad4f2e 100644 --- a/tests/regression/check19.icry.stdout +++ b/tests/regression/check19.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module [check19.cry] +Loading module Main True True True diff --git a/tests/regression/check20.icry.stdout b/tests/regression/check20.icry.stdout index e11a97c21..cdd08d402 100644 --- a/tests/regression/check20.icry.stdout +++ b/tests/regression/check20.icry.stdout @@ -1,4 +1,4 @@ Loading module Cryptol Loading module Cryptol -Loading module [check20.cry] +Loading module Main True diff --git a/tests/regression/check21.icry.stdout b/tests/regression/check21.icry.stdout index 7380c9d78..cdd08d402 100644 --- a/tests/regression/check21.icry.stdout +++ b/tests/regression/check21.icry.stdout @@ -1,4 +1,4 @@ Loading module Cryptol Loading module Cryptol -Loading module [check21.cry] +Loading module Main True diff --git a/tests/regression/check22.icry.stdout b/tests/regression/check22.icry.stdout index e58d4da8a..cdd08d402 100644 --- a/tests/regression/check22.icry.stdout +++ b/tests/regression/check22.icry.stdout @@ -1,4 +1,4 @@ Loading module Cryptol Loading module Cryptol -Loading module [check22.cry] +Loading module Main True diff --git a/tests/regression/check23.icry.stdout b/tests/regression/check23.icry.stdout index 5123f393c..cdd08d402 100644 --- a/tests/regression/check23.icry.stdout +++ b/tests/regression/check23.icry.stdout @@ -1,4 +1,4 @@ Loading module Cryptol Loading module Cryptol -Loading module [check23.cry] +Loading module Main True diff --git a/tests/regression/check24.icry.stdout b/tests/regression/check24.icry.stdout index 6808a6e73..cdd08d402 100644 --- a/tests/regression/check24.icry.stdout +++ b/tests/regression/check24.icry.stdout @@ -1,4 +1,4 @@ Loading module Cryptol Loading module Cryptol -Loading module [check24.cry] +Loading module Main True diff --git a/tests/regression/check26.icry.stdout b/tests/regression/check26.icry.stdout index d4a9a8742..cdd08d402 100644 --- a/tests/regression/check26.icry.stdout +++ b/tests/regression/check26.icry.stdout @@ -1,4 +1,4 @@ Loading module Cryptol Loading module Cryptol -Loading module [check26.cry] +Loading module Main True diff --git a/tests/regression/check27.icry.stdout b/tests/regression/check27.icry.stdout index 79f4731b1..cdd08d402 100644 --- a/tests/regression/check27.icry.stdout +++ b/tests/regression/check27.icry.stdout @@ -1,4 +1,4 @@ Loading module Cryptol Loading module Cryptol -Loading module [check27.cry] +Loading module Main True diff --git a/tests/regression/check28.icry.stdout b/tests/regression/check28.icry.stdout index b1e99d33e..cdd08d402 100644 --- a/tests/regression/check28.icry.stdout +++ b/tests/regression/check28.icry.stdout @@ -1,4 +1,4 @@ Loading module Cryptol Loading module Cryptol -Loading module [check28.cry] +Loading module Main True diff --git a/tests/regression/check29.icry.stdout b/tests/regression/check29.icry.stdout index 8121d6de7..57a1d7a1c 100644 --- a/tests/regression/check29.icry.stdout +++ b/tests/regression/check29.icry.stdout @@ -1,3 +1,3 @@ Loading module Cryptol Loading module Cryptol -Loading module [check29.cry] +Loading module Main diff --git a/tests/regression/check30.icry.stdout b/tests/regression/check30.icry.stdout index 4d6e677cb..1dedb89b0 100644 --- a/tests/regression/check30.icry.stdout +++ b/tests/regression/check30.icry.stdout @@ -1,8 +1,8 @@ Loading module Cryptol Loading module Cryptol -Loading module [check30.cry] +Loading module Main [warning] at check30.cry:2:13--2:14 This binding for `x` shadows the existing binding at check30.cry:1:1--1:2 Loading module Cryptol -Loading module [check30.cry] +Loading module Main diff --git a/tests/regression/cplx.icry.stdout b/tests/regression/cplx.icry.stdout index e25960370..e34a6ebdf 100644 --- a/tests/regression/cplx.icry.stdout +++ b/tests/regression/cplx.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module [cplx.cry] +Loading module Main {real = (ratio 420 1), imag = (ratio 0 1)} {real = (ratio 10 1), imag = (ratio 10 1)} {real = (ratio 43 1), imag = (ratio 1 1)} @@ -18,7 +18,7 @@ Testing... Passed 100 tests. :prove cplxMulDistrib Q.E.D. Loading module Cryptol -Loading module [cplxbroken.cry] +Loading module Main property cplxAddAssoc Using random testing. Testing... Passed 100 tests. property cplxMulAssoc Using random testing. diff --git a/tests/regression/dumptests.icry.stdout b/tests/regression/dumptests.icry.stdout index cf2599f56..57a1d7a1c 100644 --- a/tests/regression/dumptests.icry.stdout +++ b/tests/regression/dumptests.icry.stdout @@ -1,3 +1,3 @@ Loading module Cryptol Loading module Cryptol -Loading module [dumptests.cry] +Loading module Main diff --git a/tests/regression/f2polytest.icry.stdout b/tests/regression/f2polytest.icry.stdout index fc94c547a..24a4c0be5 100644 --- a/tests/regression/f2polytest.icry.stdout +++ b/tests/regression/f2polytest.icry.stdout @@ -1,7 +1,7 @@ Loading module Cryptol Loading module Cryptol Loading module Cryptol::Reference -Loading module [f2polytest.cry] +Loading module Main property mult3_9 Using random testing. Testing... Passed 2000 tests. Expected test coverage: 11.49% (1883 of 16384 values) diff --git a/tests/regression/negshift.icry.stdout b/tests/regression/negshift.icry.stdout index 064ac5b67..2391954e1 100644 --- a/tests/regression/negshift.icry.stdout +++ b/tests/regression/negshift.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module [negshift.cry] +Loading module Main property nls1 Using random testing. Testing... Passed 1000 tests. property nls2 Using random testing. diff --git a/tests/regression/poly.icry.stdout b/tests/regression/poly.icry.stdout index 338e1b205..f5455c823 100644 --- a/tests/regression/poly.icry.stdout +++ b/tests/regression/poly.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module [poly.cry] +Loading module Main {coeffs = [0, 2]} {coeffs = [0, 0, 1]} property polySquare Using random testing. diff --git a/tests/regression/primes.icry.stdout b/tests/regression/primes.icry.stdout index b00ccbdd5..dfaf748d9 100644 --- a/tests/regression/primes.icry.stdout +++ b/tests/regression/primes.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module [primes.cry] +Loading module Main property recip_correct_17 Using exhaustive testing. Testing... Passed 17 tests. Q.E.D. diff --git a/tests/regression/r01.icry.stdout b/tests/regression/r01.icry.stdout index 2601630d9..bb355c4be 100644 --- a/tests/regression/r01.icry.stdout +++ b/tests/regression/r01.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module [r01.cry] +Loading module Main True False False diff --git a/tests/regression/r05.icry.stdout b/tests/regression/r05.icry.stdout index 9902fd8a9..57a1d7a1c 100644 --- a/tests/regression/r05.icry.stdout +++ b/tests/regression/r05.icry.stdout @@ -1,3 +1,3 @@ Loading module Cryptol Loading module Cryptol -Loading module [r05.cry] +Loading module Main diff --git a/tests/regression/rational_properties.icry.stdout b/tests/regression/rational_properties.icry.stdout index d026ad738..bfc35cd3d 100644 --- a/tests/regression/rational_properties.icry.stdout +++ b/tests/regression/rational_properties.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module [rational_properties.cry] +Loading module Main property QaddUnit Using random testing. Testing... Passed 100 tests. property QaddComm Using random testing. diff --git a/tests/regression/rec-update.icry.stdout b/tests/regression/rec-update.icry.stdout index 351a9d8cb..6da94fc66 100644 --- a/tests/regression/rec-update.icry.stdout +++ b/tests/regression/rec-update.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module [rec-update.cry] +Loading module Main [{x = 0x02, y = True}, {x = 0x03, y = True}, {x = 0x04, y = False}, {x = 0x05, y = False}] [{x = 0x07, y = True}, {x = 0x08, y = True}, diff --git a/tests/regression/reference.icry.stdout b/tests/regression/reference.icry.stdout index a86703d08..35dfdba3c 100644 --- a/tests/regression/reference.icry.stdout +++ b/tests/regression/reference.icry.stdout @@ -1,7 +1,7 @@ Loading module Cryptol Loading module Cryptol Loading module Cryptol::Reference -Loading module [reference.cry] +Loading module Main property foldl_eq Using random testing. Testing... Passed 1000 tests. property scanl_eq Using random testing. diff --git a/tests/regression/tc-errors.icry.stdout b/tests/regression/tc-errors.icry.stdout index d7f6a7608..e5e8135ed 100644 --- a/tests/regression/tc-errors.icry.stdout +++ b/tests/regression/tc-errors.icry.stdout @@ -43,22 +43,22 @@ Parse error at tc-errors.icry:7:1--7:10 Inferred type: Bit When checking user annotation Loading module Cryptol -Loading module [tc-errors-1.cry] +Loading module Main [error] at tc-errors-1.cry:1:9--1:12: Malformed type. Type variables cannot be applied to parameters. Loading module Cryptol -Loading module [tc-errors-2.cry] +Loading module Main [error] Invalid recursive dependency: - • type [tc-errors-2.cry]::T, defined at 1:6--1:7 + • type Main::T, defined at 1:6--1:7 Loading module Cryptol -Loading module [tc-errors-3.cry] +Loading module Main [error] at tc-errors-3.cry:2:1--2:6: Failed to validate user-specified signature. - in the definition of '[tc-errors-3.cry]::f', at tc-errors-3.cry:2:1--2:2, + in the definition of 'Main::f', at tc-errors-3.cry:2:1--2:2, we need to show that for any type a the following constraints hold: @@ -71,7 +71,7 @@ Loading module [tc-errors-3.cry] use of literal or demoted expression at tc-errors-3.cry:2:5--2:6 Loading module Cryptol -Loading module [tc-errors-4.cry] +Loading module Main [error] at tc-errors-4.cry:1:10--1:11: Wild card types are not allowed in this context @@ -80,18 +80,18 @@ Loading module [tc-errors-4.cry] • FFI declarations • declarations with constraint guards Loading module Cryptol -Loading module [tc-errors-5.cry] +Loading module Main [error] at tc-errors-5.cry:2:1--2:7: Inferred type is not sufficiently polymorphic. Quantified variable: a`892 cannot match type: [0]?a - When checking the type of '[tc-errors-5.cry]::f' + When checking the type of 'Main::f' where ?a is type of sequence member at tc-errors-5.cry:2:5--2:7 a`892 is signature variable 'a' at tc-errors-5.cry:1:6--1:7 Loading module Cryptol -Loading module [tc-errors-6.cry] +Loading module Main [error] at tc-errors-6.cry:4:3--4:8: The type ?a is not sufficiently polymorphic. diff --git a/tests/regression/twinmult.icry.stdout b/tests/regression/twinmult.icry.stdout index 9ee5c0e44..2a63a1cd7 100644 --- a/tests/regression/twinmult.icry.stdout +++ b/tests/regression/twinmult.icry.stdout @@ -1,7 +1,7 @@ Loading module Cryptol Loading module Cryptol Loading module PrimeEC -Loading module [twinmult.cry] +Loading module Main property twin_mult_zro Using exhaustive testing. Testing... Passed 49 tests. Q.E.D. diff --git a/tests/regression/word-update.icry.stdout b/tests/regression/word-update.icry.stdout index fd48ed9b8..3428950a8 100644 --- a/tests/regression/word-update.icry.stdout +++ b/tests/regression/word-update.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module [word-update.cry] +Loading module Main property wordUpdate Using random testing. Testing... Passed 10000 tests. Expected test coverage: 0.03% (9999 of 2^^25 values) diff --git a/tests/regression/xor-precedence.icry.stdout b/tests/regression/xor-precedence.icry.stdout index 224351f99..3ba9606f4 100644 --- a/tests/regression/xor-precedence.icry.stdout +++ b/tests/regression/xor-precedence.icry.stdout @@ -1,4 +1,4 @@ Loading module Cryptol Loading module Cryptol -Loading module [xor-precedence.cry] +Loading module Main False diff --git a/tests/suiteb/ECDSAKeyPair.icry.stdout b/tests/suiteb/ECDSAKeyPair.icry.stdout index 7f0da9a04..725fc4c46 100644 --- a/tests/suiteb/ECDSAKeyPair.icry.stdout +++ b/tests/suiteb/ECDSAKeyPair.icry.stdout @@ -2,7 +2,7 @@ Loading module Cryptol Loading module Cryptol Loading module PrimeEC Loading module NISTCurves -Loading module [ECDSAKeyPair.cry] +Loading module Main property p192_keypair_test Using exhaustive testing. Testing... Passed 1 tests. Q.E.D. diff --git a/tests/suiteb/ECDSASigGen.icry.stdout b/tests/suiteb/ECDSASigGen.icry.stdout index a535780b4..992830bcf 100644 --- a/tests/suiteb/ECDSASigGen.icry.stdout +++ b/tests/suiteb/ECDSASigGen.icry.stdout @@ -3,7 +3,7 @@ Loading module Cryptol Loading module PrimeEC Loading module NISTCurves Loading module SuiteB -Loading module [ECDSASigGen.cry] +Loading module Main property p192_valid_curve Using exhaustive testing. Testing... Passed 1 tests. Q.E.D. diff --git a/tests/suiteb/ECDSASigVerify.icry.stdout b/tests/suiteb/ECDSASigVerify.icry.stdout index 9707f60de..b6100ef4d 100644 --- a/tests/suiteb/ECDSASigVerify.icry.stdout +++ b/tests/suiteb/ECDSASigVerify.icry.stdout @@ -3,7 +3,7 @@ Loading module Cryptol Loading module PrimeEC Loading module NISTCurves Loading module SuiteB -Loading module [ECDSASigVerify.cry] +Loading module Main property p192_valid_curve Using exhaustive testing. Testing... Passed 1 tests. Q.E.D. diff --git a/tests/suiteb/aes-mct-ecb.icry.stdout b/tests/suiteb/aes-mct-ecb.icry.stdout index 2f2af5372..9da27a2be 100644 --- a/tests/suiteb/aes-mct-ecb.icry.stdout +++ b/tests/suiteb/aes-mct-ecb.icry.stdout @@ -1,7 +1,7 @@ Loading module Cryptol Loading module Cryptol Loading module SuiteB -Loading module [aes-mct-ecb.cry] +Loading module Main property aes128_MCT_vectors_encrypt_correct Using exhaustive testing. Testing... Passed 1 tests. Q.E.D. diff --git a/tests/suiteb/aes-vectors.icry.stdout b/tests/suiteb/aes-vectors.icry.stdout index a7b9fb5fb..e29bff4a5 100644 --- a/tests/suiteb/aes-vectors.icry.stdout +++ b/tests/suiteb/aes-vectors.icry.stdout @@ -1,7 +1,7 @@ Loading module Cryptol Loading module Cryptol Loading module SuiteB -Loading module [aes-vectors.cry] +Loading module Main property aes128_GFSBox_encrypt_correct Using exhaustive testing. Testing... Passed 1 tests. Q.E.D. diff --git a/tests/suiteb/sha224-mct.icry.stdout b/tests/suiteb/sha224-mct.icry.stdout index bd34b3bf2..3aff82d13 100644 --- a/tests/suiteb/sha224-mct.icry.stdout +++ b/tests/suiteb/sha224-mct.icry.stdout @@ -1,7 +1,7 @@ Loading module Cryptol Loading module Cryptol Loading module SuiteB -Loading module [sha224-mct.cry] +Loading module Main property sha224_mct_correct Using exhaustive testing. Testing... Passed 1 tests. Q.E.D. diff --git a/tests/suiteb/sha224-vectors-long.icry.stdout b/tests/suiteb/sha224-vectors-long.icry.stdout index 9f681969e..1e42c46f6 100644 --- a/tests/suiteb/sha224-vectors-long.icry.stdout +++ b/tests/suiteb/sha224-vectors-long.icry.stdout @@ -1,7 +1,7 @@ Loading module Cryptol Loading module Cryptol Loading module SuiteB -Loading module [sha224-vectors-long.cry] +Loading module Main property sha224_long611 Using exhaustive testing. Testing... Passed 1 tests. Q.E.D. diff --git a/tests/suiteb/sha224-vectors-short.icry.stdout b/tests/suiteb/sha224-vectors-short.icry.stdout index d72485eb5..963e30062 100644 --- a/tests/suiteb/sha224-vectors-short.icry.stdout +++ b/tests/suiteb/sha224-vectors-short.icry.stdout @@ -1,7 +1,7 @@ Loading module Cryptol Loading module Cryptol Loading module SuiteB -Loading module [sha224-vectors-short.cry] +Loading module Main property sha224_short0 Using exhaustive testing. Testing... Passed 1 tests. Q.E.D. diff --git a/tests/suiteb/sha256-mct.icry.stdout b/tests/suiteb/sha256-mct.icry.stdout index 9d846f5dc..b3ea55376 100644 --- a/tests/suiteb/sha256-mct.icry.stdout +++ b/tests/suiteb/sha256-mct.icry.stdout @@ -1,7 +1,7 @@ Loading module Cryptol Loading module Cryptol Loading module SuiteB -Loading module [sha256-mct.cry] +Loading module Main property sha256_mct_correct Using exhaustive testing. Testing... Passed 1 tests. Q.E.D. diff --git a/tests/suiteb/sha256-vectors-long.icry.stdout b/tests/suiteb/sha256-vectors-long.icry.stdout index be9abb46c..47379f397 100644 --- a/tests/suiteb/sha256-vectors-long.icry.stdout +++ b/tests/suiteb/sha256-vectors-long.icry.stdout @@ -1,7 +1,7 @@ Loading module Cryptol Loading module Cryptol Loading module SuiteB -Loading module [sha256-vectors-long.cry] +Loading module Main property sha256_long611 Using exhaustive testing. Testing... Passed 1 tests. Q.E.D. diff --git a/tests/suiteb/sha256-vectors-short.icry.stdout b/tests/suiteb/sha256-vectors-short.icry.stdout index 6ae2819b7..892a8d7cd 100644 --- a/tests/suiteb/sha256-vectors-short.icry.stdout +++ b/tests/suiteb/sha256-vectors-short.icry.stdout @@ -1,7 +1,7 @@ Loading module Cryptol Loading module Cryptol Loading module SuiteB -Loading module [sha256-vectors-short.cry] +Loading module Main property sha256_short0 Using exhaustive testing. Testing... Passed 1 tests. Q.E.D. diff --git a/tests/suiteb/sha384-mct.icry.stdout b/tests/suiteb/sha384-mct.icry.stdout index 938f85d45..cab1d26c8 100644 --- a/tests/suiteb/sha384-mct.icry.stdout +++ b/tests/suiteb/sha384-mct.icry.stdout @@ -1,7 +1,7 @@ Loading module Cryptol Loading module Cryptol Loading module SuiteB -Loading module [sha384-mct.cry] +Loading module Main property sha384_mct_correct Using exhaustive testing. Testing... Passed 1 tests. Q.E.D. diff --git a/tests/suiteb/sha384-vectors-long.icry.stdout b/tests/suiteb/sha384-vectors-long.icry.stdout index 374293ac3..7fe5c6b64 100644 --- a/tests/suiteb/sha384-vectors-long.icry.stdout +++ b/tests/suiteb/sha384-vectors-long.icry.stdout @@ -1,7 +1,7 @@ Loading module Cryptol Loading module Cryptol Loading module SuiteB -Loading module [sha384-vectors-long.cry] +Loading module Main property sha384_long1123 Using exhaustive testing. Testing... Passed 1 tests. Q.E.D. diff --git a/tests/suiteb/sha384-vectors-short.icry.stdout b/tests/suiteb/sha384-vectors-short.icry.stdout index 2251e62e1..f985f31ba 100644 --- a/tests/suiteb/sha384-vectors-short.icry.stdout +++ b/tests/suiteb/sha384-vectors-short.icry.stdout @@ -1,7 +1,7 @@ Loading module Cryptol Loading module Cryptol Loading module SuiteB -Loading module [sha384-vectors-short.cry] +Loading module Main property sha384_short0 Using exhaustive testing. Testing... Passed 1 tests. Q.E.D. diff --git a/tests/suiteb/sha512-mct.icry.stdout b/tests/suiteb/sha512-mct.icry.stdout index 77f87fbfe..ebe14c2b3 100644 --- a/tests/suiteb/sha512-mct.icry.stdout +++ b/tests/suiteb/sha512-mct.icry.stdout @@ -1,7 +1,7 @@ Loading module Cryptol Loading module Cryptol Loading module SuiteB -Loading module [sha512-mct.cry] +Loading module Main property sha512_mct_correct Using exhaustive testing. Testing... Passed 1 tests. Q.E.D. diff --git a/tests/suiteb/sha512-vectors-long.icry.stdout b/tests/suiteb/sha512-vectors-long.icry.stdout index a420567bf..24e131ec9 100644 --- a/tests/suiteb/sha512-vectors-long.icry.stdout +++ b/tests/suiteb/sha512-vectors-long.icry.stdout @@ -1,7 +1,7 @@ Loading module Cryptol Loading module Cryptol Loading module SuiteB -Loading module [sha512-vectors-long.cry] +Loading module Main property sha512_long1123 Using exhaustive testing. Testing... Passed 1 tests. Q.E.D. diff --git a/tests/suiteb/sha512-vectors-short.icry.stdout b/tests/suiteb/sha512-vectors-short.icry.stdout index 3bfa0d338..0bc35a96e 100644 --- a/tests/suiteb/sha512-vectors-short.icry.stdout +++ b/tests/suiteb/sha512-vectors-short.icry.stdout @@ -1,7 +1,7 @@ Loading module Cryptol Loading module Cryptol Loading module SuiteB -Loading module [sha512-vectors-short.cry] +Loading module Main property sha512_short0 Using exhaustive testing. Testing... Passed 1 tests. Q.E.D. From 33826df168fccda185dadf7f0746d179300da762 Mon Sep 17 00:00:00 2001 From: Bretton Date: Wed, 21 Jun 2023 16:29:07 -0700 Subject: [PATCH 08/35] Name parameterized main modules in tests --- examples/AE.cry | 1 + tests/examples/allexamples.icry.stdout | 4 ++-- tests/issues/T1440.cry | 2 ++ tests/issues/T1440.icry.stdout | 10 +++++----- tests/issues/T1494_1.cry | 1 + tests/issues/T1494_1.icry.stdout | 4 ++-- tests/issues/issue731.cry | 2 ++ tests/issues/issue731.icry | 2 +- tests/issues/issue731.icry.stdout | 2 +- 9 files changed, 17 insertions(+), 11 deletions(-) diff --git a/examples/AE.cry b/examples/AE.cry index 1ac25e774..333e4b051 100644 --- a/examples/AE.cry +++ b/examples/AE.cry @@ -5,6 +5,7 @@ Implementation of the algorithms from the paper "Automated Analysis and Synthesis of Authenticated Encryption Schemes" by Viet Tung Hoang, Jonathan Katz, and Alex J. Malozemoff */ +module AE where parameter type A : * // State type diff --git a/tests/examples/allexamples.icry.stdout b/tests/examples/allexamples.icry.stdout index c5972d2b7..6ac8d480c 100644 --- a/tests/examples/allexamples.icry.stdout +++ b/tests/examples/allexamples.icry.stdout @@ -1,7 +1,7 @@ Loading module Cryptol Loading module Cryptol -Loading interface module `parameter` interface of Main -Loading module Main +Loading interface module `parameter` interface of AE +Loading module AE Loading module Cryptol Loading module AES Loading module Cryptol diff --git a/tests/issues/T1440.cry b/tests/issues/T1440.cry index 089285c1e..86e51e877 100644 --- a/tests/issues/T1440.cry +++ b/tests/issues/T1440.cry @@ -1,3 +1,5 @@ +module T1440 where + import interface submodule X import submodule Y diff --git a/tests/issues/T1440.icry.stdout b/tests/issues/T1440.icry.stdout index 12b4d1ca6..d74531fc9 100644 --- a/tests/issues/T1440.icry.stdout +++ b/tests/issues/T1440.icry.stdout @@ -1,12 +1,12 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module T1440 -[error] at T1440.cry:1:28--1:29 +[error] at T1440.cry:3:28--3:29 Module not in scope: X -[error] at T1440.cry:3:1--3:19 +[error] at T1440.cry:5:1--5:19 Module not in scope: Y -[error] at T1440.cry:14:40--14:42 +[error] at T1440.cry:16:40--16:42 Module not in scope: U1 -[error] at T1440.cry:15:26--15:28 +[error] at T1440.cry:17:26--17:28 Module not in scope: U2 diff --git a/tests/issues/T1494_1.cry b/tests/issues/T1494_1.cry index d60028501..621d6014a 100644 --- a/tests/issues/T1494_1.cry +++ b/tests/issues/T1494_1.cry @@ -1,3 +1,4 @@ +module T1494_1 where parameter type n : # diff --git a/tests/issues/T1494_1.icry.stdout b/tests/issues/T1494_1.icry.stdout index f57e993b3..90190df26 100644 --- a/tests/issues/T1494_1.icry.stdout +++ b/tests/issues/T1494_1.icry.stdout @@ -1,4 +1,4 @@ Loading module Cryptol Loading module Cryptol -Loading interface module `parameter` interface of Main -Loading module Main +Loading interface module `parameter` interface of T1494_1 +Loading module T1494_1 diff --git a/tests/issues/issue731.cry b/tests/issues/issue731.cry index 726a6605b..37d6c3f64 100644 --- a/tests/issues/issue731.cry +++ b/tests/issues/issue731.cry @@ -1,3 +1,5 @@ +module issue731 where + type constraint T n = (fin n, n >= 1) type constraint Both p q = (p, q) diff --git a/tests/issues/issue731.icry b/tests/issues/issue731.icry index 241ac1980..5a2d57d7e 100644 --- a/tests/issues/issue731.icry +++ b/tests/issues/issue731.icry @@ -1,2 +1,2 @@ :l issue731.cry -:browse Main +:browse issue731 diff --git a/tests/issues/issue731.icry.stdout b/tests/issues/issue731.icry.stdout index d97ed83b8..177c7159a 100644 --- a/tests/issues/issue731.icry.stdout +++ b/tests/issues/issue731.icry.stdout @@ -1,6 +1,6 @@ Loading module Cryptol Loading module Cryptol -Loading module Main +Loading module issue731 Constraint Synonyms =================== From 8ada88ad776aefbd8658d06907504bd347c8d4b6 Mon Sep 17 00:00:00 2001 From: Bretton Date: Wed, 21 Jun 2023 16:29:51 -0700 Subject: [PATCH 09/35] Change displayed name of main modules back to Main --- src/Cryptol/Utils/Ident.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Cryptol/Utils/Ident.hs b/src/Cryptol/Utils/Ident.hs index 08c19ab42..34f952307 100644 --- a/src/Cryptol/Utils/Ident.hs +++ b/src/Cryptol/Utils/Ident.hs @@ -202,7 +202,7 @@ modNamesMatch _ _ = False modNameToText :: ModName -> Text modNameToText (ModName x fl) = maybeAnonText fl x -modNameToText (ModMain f) = "[" <> T.pack f <> "]" +modNameToText (ModMain _) = "Main" -- | This is useful when we want to hide anonymous modules. modNameIsNormal :: ModName -> Bool From 6a376ab8b0d838955b3ab77ef2148e8d8b594ce4 Mon Sep 17 00:00:00 2001 From: Bretton Date: Wed, 12 Jul 2023 10:21:01 -0700 Subject: [PATCH 10/35] Projects: Add caching for loading modules --- cryptol-remote-api/src/CryptolServer.hs | 2 +- .../src/CryptolServer/FileDeps.hs | 3 +- src/Cryptol/ModuleSystem/Base.hs | 59 +++-- src/Cryptol/ModuleSystem/Env.hs | 46 ++-- src/Cryptol/ModuleSystem/Fingerprint.hs | 12 +- src/Cryptol/ModuleSystem/Monad.hs | 5 + src/Cryptol/Parser/NoInclude.hs | 22 +- src/Cryptol/Project.hs | 211 +++++++++++++++--- src/Cryptol/REPL/Command.hs | 4 +- src/Cryptol/Utils/Ident.hs | 3 +- 10 files changed, 289 insertions(+), 78 deletions(-) diff --git a/cryptol-remote-api/src/CryptolServer.hs b/cryptol-remote-api/src/CryptolServer.hs index bacf3f2b2..31c1e01a0 100644 --- a/cryptol-remote-api/src/CryptolServer.hs +++ b/cryptol-remote-api/src/CryptolServer.hs @@ -195,6 +195,6 @@ validateServerState = InMem{} -> continue InFile file -> do fp <- fingerprintFile file - if fp == Just (fiFingerprint (lmFileInfo lm)) + if fp == Right (fiFingerprint (lmFileInfo lm)) then continue else return False diff --git a/cryptol-remote-api/src/CryptolServer/FileDeps.hs b/cryptol-remote-api/src/CryptolServer/FileDeps.hs index 0318badf0..e79cda5cd 100644 --- a/cryptol-remote-api/src/CryptolServer/FileDeps.hs +++ b/cryptol-remote-api/src/CryptolServer/FileDeps.hs @@ -9,6 +9,7 @@ module CryptolServer.FileDeps import Data.Text (Text) import qualified Data.Map as Map import qualified Data.Set as Set +import qualified Data.Map.Strict as Map import qualified Data.Aeson as JSON import Data.Aeson (FromJSON(..),ToJSON(..),(.=),(.:)) @@ -67,7 +68,7 @@ instance ToJSON FileDeps where InFile f -> toJSON f InMem l _ -> JSON.object [ "internal" .= l ] , "fingerprint" .= fingerprintHexString (fiFingerprint fi) - , "includes" .= Set.toList (fiIncludeDeps fi) + , "includes" .= Map.keys (fiIncludeDeps fi) , "imports" .= map (show . pp) (Set.toList (fiImportDeps fi)) , "foreign" .= Map.toList (fiForeignDeps fi) ] diff --git a/src/Cryptol/ModuleSystem/Base.hs b/src/Cryptol/ModuleSystem/Base.hs index c6eda8f6a..c9aa645dc 100644 --- a/src/Cryptol/ModuleSystem/Base.hs +++ b/src/Cryptol/ModuleSystem/Base.hs @@ -41,6 +41,7 @@ import System.FilePath ( addExtension ) import qualified System.IO.Error as IOE import qualified Data.Map as Map +import qualified Data.Map.Strict as MapS import Prelude () import Prelude.Compat hiding ( (<>) ) @@ -159,7 +160,8 @@ expandPropGuards a = -- Returns a fingerprint of the module, and a set of dependencies due -- to `include` directives. parseModule :: - ModulePath -> ModuleM (Fingerprint, Set FilePath, [P.Module PName]) + ModulePath -> + ModuleM (Fingerprint, MapS.Map FilePath Fingerprint, [P.Module PName]) parseModule path = do getBytes <- getByteReader @@ -203,7 +205,7 @@ parseModule path = do case mb of Right ok -> pure ok Left err -> noIncludeErrors err - pure (mo, Set.unions d) + pure (mo, MapS.unions d) {- We don't do "include" resolution for in-memory files because at the moment the include resolution pass requires @@ -211,7 +213,7 @@ parseModule path = do looking for other inlcude files. This could be generalized, but we can do it once we have a concrete use case as it would help guide the design. -} - InMem {} -> pure (pms, Set.empty) + InMem {} -> pure (pms, MapS.empty) {- case path of @@ -248,7 +250,8 @@ loadModuleByPath eval path = withPrependedSearchPath [ takeDirectory path ] $ do case lookupTCEntity n env of -- loadModule will calculate the canonical path again Nothing -> - doLoadModule eval False (FromModule n) (InFile foundPath) fp deps pm + loadModuleAndDeps eval False + (FromModule n) (InFile foundPath) fp deps pm Just lm | path' == loaded -> return (lmData lm) | otherwise -> duplicateModuleName n path' loaded @@ -267,25 +270,38 @@ loadModuleFrom quiet isrc = do path <- findModule n errorInFile path $ do (fp, deps, pms) <- parseModule path - ms <- mapM (doLoadModule True quiet isrc path fp deps) pms + ms <- mapM (loadModuleAndDeps True quiet isrc path fp deps) pms return (path,last ms) -- | Load dependencies, typecheck, and add to the eval environment. -doLoadModule :: +loadModuleAndDeps :: Bool {- ^ evaluate declarations in the module -} -> Bool {- ^ quiet mode: true suppresses the "loading module" message -} -> ImportSource -> ModulePath -> Fingerprint -> - Set FilePath {- ^ `include` dependencies -} -> + MapS.Map FilePath Fingerprint {- ^ `include` dependencies -} -> P.Module PName -> ModuleM T.TCTopEntity -doLoadModule eval quiet isrc path fp incDeps pm0 = +loadModuleAndDeps eval quiet isrc path fp incDeps pm0 = loading isrc $ do let pm = addPrelude pm0 impDeps <- loadDeps pm + fst <$> doLoadModule eval quiet isrc path fp incDeps pm impDeps - let what = case P.mDef pm of +-- | Typecheck and add to the eval environment. +doLoadModule :: + Bool {- ^ evaluate declarations in the module -} -> + Bool {- ^ quiet mode: true suppresses the "loading module" message -} -> + ImportSource -> + ModulePath -> + Fingerprint -> + MapS.Map FilePath Fingerprint {- ^ `include` dependencies -} -> + P.Module PName -> + Set ModName -> + ModuleM (T.TCTopEntity, FileInfo) +doLoadModule eval quiet isrc path fp incDeps pm impDeps = + do let what = case P.mDef pm of P.InterfaceModule {} -> "interface module" _ -> "module" @@ -315,7 +331,7 @@ doLoadModule eval quiet isrc path fp incDeps pm0 = let fi = fileInfo fp incDeps impDeps foreignSrc loadedModule path fi nameEnv foreignSrc tcm - return tcm + return (tcm, fi) where evalForeign tcm @@ -467,10 +483,21 @@ findDepsOfModule m = findDepsOf mpath findDepsOf :: ModulePath -> ModuleM (ModulePath, FileInfo) -findDepsOf mpath = +findDepsOf mpath' = + do mpath <- case mpath' of + InFile file -> InFile <$> io (canonicalizePath file) + InMem {} -> pure mpath' + (fi, _) <- findDepsOf' mpath + pure (mpath, fi) + +findDepsOf' :: ModulePath -> + ModuleM (FileInfo, [(Module PName, [ImportSource])]) +findDepsOf' mpath = do (fp, incs, ms) <- parseModule mpath - let (anyF,imps) = mconcat (map (findDeps' . addPrelude) ms) - fdeps <- if getAny anyF + let ms' = map addPrelude ms + depss = map findDeps' ms' + let (anyF,imps) = mconcat depss + fpath <- if getAny anyF then do mb <- io case mpath of InFile path -> foreignLibPath path InMem {} -> pure Nothing @@ -480,13 +507,13 @@ findDepsOf mpath = Map.singleton fpath exists else pure Map.empty pure - ( mpath - , FileInfo + ( FileInfo { fiFingerprint = fp , fiIncludeDeps = incs , fiImportDeps = Set.fromList (map importedModule (appEndo imps [])) - , fiForeignDeps = fdeps + , fiForeignDeps = fpath } + , zip ms' $ map ((`appEndo` []) . snd) depss ) -- | Find the set of top-level modules imported by a module. diff --git a/src/Cryptol/ModuleSystem/Env.hs b/src/Cryptol/ModuleSystem/Env.hs index e37785b62..340ab3d93 100644 --- a/src/Cryptol/ModuleSystem/Env.hs +++ b/src/Cryptol/ModuleSystem/Env.hs @@ -360,7 +360,7 @@ focusedEnv me = -- | The location of a module data ModulePath = InFile FilePath | InMem String ByteString -- ^ Label, content - deriving (Show, Generic, NFData) + deriving (Show, Read, Generic, NFData) -- | In-memory things are compared by label. instance Eq ModulePath where @@ -426,11 +426,18 @@ getLoadedEntities lm = getLoadedModules :: LoadedModules -> [LoadedModule] getLoadedModules x = lmLoadedParamModules x ++ lmLoadedModules x +getLoadedField :: Ord a => + (forall b. LoadedModuleG b -> a) -> LoadedModules -> Set a +getLoadedField f lm = Set.fromList + $ map f (lmLoadedModules lm) + ++ map f (lmLoadedParamModules lm) + ++ map f (lmLoadedSignatures lm) + getLoadedNames :: LoadedModules -> Set ModName -getLoadedNames lm = Set.fromList - $ map lmName (lmLoadedModules lm) - ++ map lmName (lmLoadedParamModules lm) - ++ map lmName (lmLoadedSignatures lm) +getLoadedNames = getLoadedField lmName + +getLoadedIds :: LoadedModules -> Set String +getLoadedIds = getLoadedField lmModuleId instance Semigroup LoadedModules where l <> r = LoadedModules @@ -503,6 +510,10 @@ isLoaded (ImpNested nn) lm = any (check . lmModule) (getLoadedModules lm) Map.member nn (T.mSubmodules m) || any check (T.mFunctors m) +isLoadedStrict :: ImpName Name -> String -> LoadedModules -> Bool +isLoadedStrict mn modId lm = + isLoaded mn lm && modId `Set.member` getLoadedIds lm + -- | Is this a loaded parameterized module. isLoadedParamMod :: ImpName Name -> LoadedModules -> Bool isLoadedParamMod (ImpTop mn) lm = any ((mn ==) . lmName) (lmLoadedParamModules lm) @@ -568,13 +579,20 @@ lookupTCEntity m env = -- | Try to find a previously loaded module lookupModule :: ModName -> ModuleEnv -> Maybe LoadedModule -lookupModule mn me = search lmLoadedModules `mplus` search lmLoadedParamModules +lookupModule mn = lookupModuleWith ((mn ==) . lmName) + +lookupModuleWith :: (LoadedModule -> Bool) -> ModuleEnv -> Maybe LoadedModule +lookupModuleWith p me = + search lmLoadedModules `mplus` search lmLoadedParamModules where - search how = List.find ((mn ==) . lmName) (how (meLoadedModules me)) + search how = List.find p (how (meLoadedModules me)) lookupSignature :: ModName -> ModuleEnv -> Maybe LoadedSignature -lookupSignature mn me = - List.find ((mn ==) . lmName) (lmLoadedSignatures (meLoadedModules me)) +lookupSignature mn = lookupSignatureWith ((mn ==) . lmName) + +lookupSignatureWith :: + (LoadedSignature -> Bool) -> ModuleEnv -> Maybe LoadedSignature +lookupSignatureWith p me = List.find p (lmLoadedSignatures (meLoadedModules me)) addLoadedSignature :: ModulePath -> String -> @@ -583,7 +601,7 @@ addLoadedSignature :: ModName -> T.ModParamNames -> LoadedModules -> LoadedModules addLoadedSignature path ident fi nameEnv nm si lm - | isLoaded (ImpTop nm) lm = lm + | isLoadedStrict (ImpTop nm) ident lm = lm | otherwise = lm { lmLoadedSignatures = loaded : lmLoadedSignatures lm } where loaded = LoadedModule @@ -605,7 +623,7 @@ addLoadedModule :: Maybe ForeignSrc -> T.Module -> LoadedModules -> LoadedModules addLoadedModule path ident fi nameEnv fsrc tm lm - | isLoaded (ImpTop (T.mName tm)) lm = lm + | isLoadedStrict (ImpTop (T.mName tm)) ident lm = lm | T.isParametrizedModule tm = lm { lmLoadedParamModules = loaded : lmLoadedParamModules lm } | otherwise = lm { lmLoadedModules = @@ -640,15 +658,15 @@ removeLoadedModule rm lm = data FileInfo = FileInfo { fiFingerprint :: Fingerprint - , fiIncludeDeps :: Set FilePath + , fiIncludeDeps :: Map FilePath Fingerprint , fiImportDeps :: Set ModName - , fiForeignDeps :: Map FilePath Bool + , fiForeignDeps :: Map FilePath Bool -- ^ Foreign dependencies and whether or not they currently exist } deriving (Show,Generic,NFData) fileInfo :: Fingerprint -> - Set FilePath -> + Map FilePath Fingerprint -> Set ModName -> Maybe ForeignSrc -> FileInfo diff --git a/src/Cryptol/ModuleSystem/Fingerprint.hs b/src/Cryptol/ModuleSystem/Fingerprint.hs index 6439ec9dd..2fa9dfac2 100644 --- a/src/Cryptol/ModuleSystem/Fingerprint.hs +++ b/src/Cryptol/ModuleSystem/Fingerprint.hs @@ -13,6 +13,7 @@ module Cryptol.ModuleSystem.Fingerprint , fingerprintHexString ) where +import Control.Monad ((<$!>)) import Control.DeepSeq (NFData (rnf)) import Crypto.Hash.SHA1 (hash) import Data.ByteString (ByteString) @@ -21,7 +22,7 @@ import qualified Data.ByteString as B import qualified Data.Vector as Vector newtype Fingerprint = Fingerprint ByteString - deriving (Eq, Show) + deriving (Eq, Ord, Show, Read) instance NFData Fingerprint where rnf (Fingerprint fp) = rnf fp @@ -31,14 +32,11 @@ fingerprint :: ByteString -> Fingerprint fingerprint = Fingerprint . hash -- | Attempt to compute the fingerprint of the file at the given path. --- Returns 'Nothing' in the case of an error. -fingerprintFile :: FilePath -> IO (Maybe Fingerprint) +-- Returns 'Left' in the case of an error. +fingerprintFile :: FilePath -> IO (Either IOError Fingerprint) fingerprintFile path = do res <- try (B.readFile path) - return $! - case res :: Either IOError ByteString of - Left{} -> Nothing - Right b -> Just $! fingerprint b + return $! fingerprint <$!> (res :: Either IOError ByteString) fingerprintHexString :: Fingerprint -> String fingerprintHexString (Fingerprint bs) = B.foldr hex "" bs diff --git a/src/Cryptol/ModuleSystem/Monad.hs b/src/Cryptol/ModuleSystem/Monad.hs index 90e1193dd..dc38bea67 100644 --- a/src/Cryptol/ModuleSystem/Monad.hs +++ b/src/Cryptol/ModuleSystem/Monad.hs @@ -435,6 +435,11 @@ isLoaded mn = do env <- ModuleT get pure (MEnv.isLoaded (T.ImpTop mn) (meLoadedModules env)) +isLoadedStrict :: P.ModName -> ModulePath -> ModuleM Bool +isLoadedStrict mn mpath = + do env <- ModuleT get + pure (MEnv.isLoadedStrict (T.ImpTop mn) (modulePathLabel mpath) (meLoadedModules env)) + loadingImport :: Located P.Import -> ModuleM a -> ModuleM a loadingImport = loading . FromImport diff --git a/src/Cryptol/Parser/NoInclude.hs b/src/Cryptol/Parser/NoInclude.hs index c04d482d1..3d761b6d0 100644 --- a/src/Cryptol/Parser/NoInclude.hs +++ b/src/Cryptol/Parser/NoInclude.hs @@ -20,8 +20,8 @@ import Control.DeepSeq import qualified Control.Exception as X import qualified Control.Monad.Fail as Fail -import Data.Set(Set) -import qualified Data.Set as Set +import Data.Map.Strict(Map) +import qualified Data.Map.Strict as Map import Data.ByteString (ByteString) import Data.Either (partitionEithers) import Data.Text(Text) @@ -38,12 +38,13 @@ import Cryptol.Parser.AST import Cryptol.Parser.LexerUtils (Config(..),defaultConfig) import Cryptol.Parser.ParserUtils import Cryptol.Parser.Unlit (guessPreProc) +import Cryptol.ModuleSystem.Fingerprint removeIncludesModule :: (FilePath -> IO ByteString) -> FilePath -> Module PName -> - IO (Either [IncludeError] (Module PName, Set FilePath)) + IO (Either [IncludeError] (Module PName, Map FilePath Fingerprint)) removeIncludesModule reader modPath m = runNoIncM reader modPath (noIncludeModule m) @@ -82,7 +83,7 @@ newtype NoIncM a = M IO )) a } -type Deps = Set FilePath +type Deps = Map FilePath Fingerprint data Env = Env { envSeen :: [Located FilePath] -- ^ Files that have been loaded @@ -106,7 +107,7 @@ runNoIncM reader sourcePath m = , envIncPath = incPath , envFileReader = reader } - Set.empty + Map.empty pure do ok <- mb pure (ok,s) @@ -135,10 +136,10 @@ fromIncPath path do Env { .. } <- ask return (envIncPath path) -addDep :: FilePath -> NoIncM () -addDep path = M +addDep :: FilePath -> Fingerprint -> NoIncM () +addDep path fp = M do s <- get - let s1 = Set.insert path s + let s1 = Map.insert path fp s s1 `seq` set s1 @@ -247,12 +248,13 @@ readInclude :: Located FilePath -> NoIncM Text readInclude path = do readBytes <- envFileReader <$> M ask file <- fromIncPath (thing path) - addDep file sourceBytes <- readBytes file `failsWith` handler sourceText <- X.evaluate (T.decodeUtf8' sourceBytes) `failsWith` handler case sourceText of Left encodingErr -> M (raise [IncludeDecodeFailed path encodingErr]) - Right txt -> return txt + Right txt -> do + addDep file (fingerprint sourceBytes) + return txt where handler :: X.IOException -> NoIncM a handler _ = includeFailed path diff --git a/src/Cryptol/Project.hs b/src/Cryptol/Project.hs index aa4f8349c..6ec662184 100644 --- a/src/Cryptol/Project.hs +++ b/src/Cryptol/Project.hs @@ -1,9 +1,11 @@ {-# LANGUAGE BlockArguments #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE DeriveGeneric #-} +{-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE LambdaCase #-} {-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE RankNTypes #-} {-# LANGUAGE RecordWildCards #-} {-# LANGUAGE TypeApplications #-} {-# LANGUAGE TypeFamilies #-} @@ -14,26 +16,35 @@ module Cryptol.Project , run ) where +import Control.Monad (unless) import Control.Monad.Except +import Control.Monad.State import Data.Aeson +import Data.Foldable import Data.Functor +import Data.Map.Strict (Map) +import qualified Data.Map.Strict as Map import Data.Maybe +import Data.Set (Set) +import qualified Data.Set as Set import Data.Traversable import Data.Yaml import GHC.Generics import System.Directory -import System.FilePath as FP +import System.FilePath as FP import System.IO.Error +import Text.Read (readMaybe) -import Data.Foldable - -import Cryptol.ModuleSystem.Base +import Cryptol.ModuleSystem.Base as M import Cryptol.ModuleSystem.Env -import Cryptol.ModuleSystem.Monad as M -import Cryptol.Parser.Unlit +import Cryptol.ModuleSystem.Fingerprint +import Cryptol.ModuleSystem.Monad as M +import Cryptol.Parser.AST import Cryptol.REPL.Command -import Cryptol.REPL.Monad as REPL -import Cryptol.Utils.PP as PP +import Cryptol.REPL.Monad as REPL +import Cryptol.Utils.Ident +import Cryptol.Utils.Logger +import Cryptol.Utils.PP as PP type family MaybeIf (opt :: Bool) t where MaybeIf 'True t = Maybe t @@ -82,32 +93,182 @@ loadConfig path = do setCurrentDirectory (takeDirectory filePath FP. root) pure Config {..} +data FullFingerprint = FullFingerprint + { moduleFingerprint :: Fingerprint + , includeFingerprints :: Map FilePath Fingerprint + , foreignFingerprints :: Set Fingerprint } + deriving (Eq, Show, Read) + +data ScanStatus + = LoadedChanged + | LoadedNotChanged + | NotLoadedNotChanged + deriving Eq + +data LoadState = LoadState + { findModuleCache :: Map (ModName, [FilePath]) ModulePath + , scanned :: Map ModulePath (FullFingerprint, ScanStatus) } + +type LoadM = StateT LoadState ModuleM + +liftCallback :: (forall a. ModuleM a -> ModuleM a) -> LoadM b -> LoadM b +liftCallback f x = StateT (f . runStateT x) + +newtype LoadCache = LoadCache + { cacheFingerprints :: Map ModulePath FullFingerprint } + deriving (Show, Read) + +metaDir, loadCachePath :: FilePath +metaDir = ".cryproject" +loadCachePath = metaDir FP. "loadcache" + +emptyLoadCache :: LoadCache +emptyLoadCache = LoadCache { cacheFingerprints = Map.empty } + run :: Config -> REPL CommandResult run Config {..} = do + canonRoot <- REPL.io $ canonicalizePath root minp <- getModuleInput (res, warnings) <- REPL.io $ runModuleM minp do - let load path = do - isDir <- M.io $ doesDirectoryExist path - if isDir - then M.io (tryIOError (listDirectory path)) >>= \case - Left err -> otherIOError path err - Right entries -> concat <$> for entries \case - '.':_ -> pure [] - entry -> load (path FP. entry) - else case takeExtension path of - '.':ext - | ext `elem` knownExts -> - pure <$> loadModuleByPath True path - _ -> pure [] - concat <$> traverse load modules + loadCache <- M.io $ + (fromMaybe emptyLoadCache . readMaybe <$> readFile loadCachePath) + `catchIOError` \_ -> pure emptyLoadCache + let scanFromPath :: FilePath -> LoadM () + scanFromPath fpath = + liftCallback (withPrependedSearchPath [takeDirectory fpath]) do + foundFPath <- lift $ M.findFile fpath + mpath <- lift $ InFile <$> M.io (canonicalizePath foundFPath) + void $ scan Nothing mpath + scan :: Maybe ImportSource -> ModulePath -> LoadM ScanStatus + scan mbIsrc mpath = do + ls <- get + case Map.lookup mpath (scanned ls) of + Just (_, status) -> pure status + Nothing -> liftCallback (errorInFile mpath) do + lift $ withLogger logPutStrLn $ + "Scanning " ++ case mpath of + InFile p -> makeRelative canonRoot p + InMem l _ -> l + (fi, pmDeps) <- lift $ findDepsOf' mpath + foreignFps <- getForeignFps $ Map.keysSet (fiForeignDeps fi) + let newFp = FullFingerprint + { moduleFingerprint = fiFingerprint fi + , includeFingerprints = fiIncludeDeps fi + , foreignFingerprints = foreignFps } + loadChanged = LoadedChanged <$ load mbIsrc mpath + (fiFingerprint fi) (fiIncludeDeps fi) pmDeps + status <- case Map.lookup mpath (cacheFingerprints loadCache) of + Just oldFp + | oldFp == newFp -> do + let currentModNames = map (thing . mName . fst) pmDeps + depStatuses <- traverse scanFromImportSource $ + filter ((`notElem` currentModNames) . importedModule) $ + concatMap snd pmDeps + if LoadedChanged `elem` depStatuses + then loadChanged + else pure NotLoadedNotChanged + _ -> loadChanged + insertScanned mpath newFp status + pure status + scanFromImportSource :: ImportSource -> LoadM ScanStatus + scanFromImportSource isrc = do + mpath <- findModule' isrc + scan (Just isrc) mpath + parseAndLoad :: ImportSource -> ModulePath -> LoadM (Fingerprint, Map FilePath Fingerprint, [FileInfo]) + parseAndLoad isrc mpath = do + (newModFp, newIncFps, pms) <- lift $ parseModule mpath + fis <- load (Just isrc) mpath newModFp newIncFps $ + map (\pm -> let pm' = addPrelude pm in (pm', findDeps pm')) pms + pure (newModFp, newIncFps, fis) + load mbIsrc mpath newModFp newIncFps pmDeps = + for pmDeps \(pm, deps) -> do + let isrc = fromMaybe (FromModule (thing (mName pm))) mbIsrc + liftCallback (loading isrc) do + traverse_ loadFromImportSource deps + lift $ fmap snd $ + doLoadModule True False isrc mpath newModFp newIncFps pm $ + Set.fromList $ map importedModule deps + getForeignFps :: Set FilePath -> LoadM (Set Fingerprint) + getForeignFps fsrcPaths = lift $ + Set.fromList <$> for (Set.toList fsrcPaths) \fsrcPath -> + M.io (fingerprintFile fsrcPath) >>= \case + Left ioe -> otherIOError fsrcPath ioe + Right fp -> pure fp + insertScanned mpath fp status = modify' \ls -> ls + { scanned = Map.insert mpath (fp, status) (scanned ls) } + findModule' :: ImportSource -> LoadM ModulePath + findModule' isrc = do + let mname = modNameToNormalModName $ importedModule isrc + searchPath <- lift M.getSearchPath + ls <- get + case Map.lookup (mname, searchPath) (findModuleCache ls) of + Just mpath -> pure mpath + Nothing -> do + mpath <- lift $ findModule mname >>= \case + InFile path -> InFile <$> M.io (canonicalizePath path) + InMem l c -> pure $ InMem l c + put ls + { findModuleCache = + Map.insert (mname, searchPath) mpath (findModuleCache ls) } + pure mpath + loadFromImportSource :: ImportSource -> LoadM () + loadFromImportSource isrc = do + mpath <- findModule' isrc + liftCallback (errorInFile mpath) do + ls' <- get + case Map.lookup mpath (scanned ls') of + Just (fp, status) -> + case status of + LoadedChanged -> pure () + LoadedNotChanged -> pure () + NotLoadedNotChanged -> do + loaded <- lift $ M.isLoadedStrict (importedModule isrc) mpath + unless loaded do + _ <- parseAndLoad isrc mpath + insertScanned mpath fp LoadedNotChanged + Nothing -> do + -- The file has not been fully loaded yet, but the individual + -- module within the file might + loaded <- lift $ M.isLoadedStrict (importedModule isrc) mpath + unless loaded do + (newModFp, newIncFps, fis) <- parseAndLoad isrc mpath + foreignFps <- getForeignFps $ + Set.unions $ map (Map.keysSet . fiForeignDeps) fis + let newFp = FullFingerprint + { moduleFingerprint = newModFp + , includeFingerprints = newIncFps + , foreignFingerprints = foreignFps } + insertScanned mpath newFp + case Map.lookup mpath (cacheFingerprints loadCache) of + Just oldFp + | oldFp == newFp -> LoadedNotChanged + _ -> LoadedChanged + ls <- flip execStateT + LoadState { findModuleCache = Map.empty, scanned = Map.empty } $ + for_ modules \p -> do + let loadPath path = do + isDir <- lift $ M.io $ doesDirectoryExist path + if isDir + then lift (M.io (tryIOError (listDirectory path))) >>= \case + Left err -> lift $ otherIOError path err + Right entries -> for_ entries \case + '.':_ -> pure () + entry -> loadPath (path FP. entry) + else case takeExtension path of + ".cry" -> scanFromPath path + _ -> pure () + loadPath p + let newLoadCache = LoadCache + { cacheFingerprints = Map.map fst (scanned ls) } + M.io do + createDirectoryIfMissing False metaDir + writeFile loadCachePath $ show newLoadCache printModuleWarnings warnings case res of Left err -> do names <- mctxNameDisp <$> REPL.getFocusedEnv rPrint $ pp $ ModuleSystemError names err pure emptyCommandResult { crSuccess = False } - Right (tops, _) -> do + Right _ -> do rPutStrLn "all loaded!" - for_ tops \t -> do - rPrint $ pp t pure emptyCommandResult diff --git a/src/Cryptol/REPL/Command.hs b/src/Cryptol/REPL/Command.hs index 9a81a377a..9c9019bdc 100644 --- a/src/Cryptol/REPL/Command.hs +++ b/src/Cryptol/REPL/Command.hs @@ -123,6 +123,7 @@ import Control.Monad.IO.Class(liftIO) import Text.Read (readMaybe) import Control.Applicative ((<|>)) import qualified Data.Set as Set +import qualified Data.Map.Strict as Map import Data.ByteString (ByteString) import qualified Data.ByteString as BS import qualified Data.ByteString.Char8 as BS8 @@ -130,7 +131,6 @@ import Data.Bits (shiftL, (.&.), (.|.)) import Data.Char (isSpace,isPunctuation,isSymbol,isAlphaNum,isAscii) import Data.Function (on) import Data.List (intercalate, nub, isPrefixOf) -import qualified Data.Map as Map import Data.Maybe (fromMaybe,mapMaybe,isNothing) import System.Environment (lookupEnv) import System.Exit (ExitCode(ExitSuccess)) @@ -1980,7 +1980,7 @@ moduleInfoCmd isFile name mapM_ (\j -> rPutStrLn (" , " ++ f j)) is rPutStrLn " ]" - depList show "includes" (Set.toList (M.fiIncludeDeps fi)) + depList show "includes" (Map.keys (M.fiIncludeDeps fi)) depList (show . show . pp) "imports" (Set.toList (M.fiImportDeps fi)) depList show "foreign" (Map.toList (M.fiForeignDeps fi)) diff --git a/src/Cryptol/Utils/Ident.hs b/src/Cryptol/Utils/Ident.hs index 34f952307..507387556 100644 --- a/src/Cryptol/Utils/Ident.hs +++ b/src/Cryptol/Utils/Ident.hs @@ -190,8 +190,7 @@ modNameIfaceMod (ModMain _) = panic "modNameIfaceMod" ["Name is not normal"] modNameToNormalModName :: ModName -> ModName modNameToNormalModName (ModName t _) = ModName t NormalName -modNameToNormalModName (ModMain _) = - panic "modNameToNormalModName" ["Main module has no normal name"] +modNameToNormalModName (ModMain p) = ModMain p -- | This is used when we check that the name of a module matches the -- file where it is defined. From 6d581751a6ff16d636470cfd0804ab1dd2fa01d8 Mon Sep 17 00:00:00 2001 From: Bretton Date: Wed, 19 Jul 2023 14:04:30 -0700 Subject: [PATCH 11/35] Projects: Switch to HsYAML for config file parsing --- cryptol.cabal | 6 ++-- src/Cryptol/Project.hs | 75 ++++++++++++++++++------------------------ 2 files changed, 35 insertions(+), 46 deletions(-) diff --git a/cryptol.cabal b/cryptol.cabal index a1db7f15a..c20de921b 100644 --- a/cryptol.cabal +++ b/cryptol.cabal @@ -46,7 +46,6 @@ library Default-language: Haskell2010 Build-depends: base >= 4.9 && < 5, - aeson, arithmoi >= 0.12, async >= 2.2 && < 2.3, base-compat >= 0.6 && < 0.13, @@ -64,6 +63,8 @@ library gitrev >= 1.0, ghc-prim, GraphSCC >= 1.0.4, + heredoc >= 0.2, + HsYAML, language-c99, language-c99-simple, libBF >= 0.6 && < 0.7, @@ -86,8 +87,7 @@ library mtl >= 2.2.1, time >= 1.6.0.1, panic >= 0.3, - what4 >= 1.4 && < 1.7, - yaml >= 0.11.11 && < 0.12 + what4 >= 1.4 && < 1.7 if impl(ghc >= 9.0) build-depends: ghc-bignum >= 1.0 && < 1.4 diff --git a/src/Cryptol/Project.hs b/src/Cryptol/Project.hs index 6ec662184..4087e4b86 100644 --- a/src/Cryptol/Project.hs +++ b/src/Cryptol/Project.hs @@ -1,14 +1,9 @@ {-# LANGUAGE BlockArguments #-} -{-# LANGUAGE DataKinds #-} -{-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE FlexibleContexts #-} -{-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE LambdaCase #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE RankNTypes #-} {-# LANGUAGE RecordWildCards #-} -{-# LANGUAGE TypeApplications #-} -{-# LANGUAGE TypeFamilies #-} module Cryptol.Project ( Config @@ -16,20 +11,20 @@ module Cryptol.Project , run ) where -import Control.Monad (unless) -import Control.Monad.Except +import Control.Monad (unless, void) import Control.Monad.State -import Data.Aeson +import Data.Bifunctor +import qualified Data.ByteString as BS.Strict +import qualified Data.ByteString.Lazy as BS.Lazy import Data.Foldable -import Data.Functor import Data.Map.Strict (Map) import qualified Data.Map.Strict as Map import Data.Maybe import Data.Set (Set) import qualified Data.Set as Set +import qualified Data.Text as Text import Data.Traversable -import Data.Yaml -import GHC.Generics +import Data.YAML import System.Directory import System.FilePath as FP import System.IO.Error @@ -46,52 +41,46 @@ import Cryptol.Utils.Ident import Cryptol.Utils.Logger import Cryptol.Utils.PP as PP -type family MaybeIf (opt :: Bool) t where - MaybeIf 'True t = Maybe t - MaybeIf 'False t = t +data Config = Config + { root :: FilePath + , modules :: [FilePath] } -data GenericConfig (opt :: Bool) = Config - { root :: MaybeIf opt FilePath - , modules :: MaybeIf opt [FilePath] } - deriving Generic - -type ParsedConfig = GenericConfig 'True -type Config = GenericConfig 'False - -instance FromJSON ParsedConfig where - parseJSON = genericParseJSON defaultOptions { rejectUnknownFields = True } +instance FromYAML Config where + parseYAML = withMap "Config" \m -> do + root <- Text.unpack <$> m .:? "root" .!= "." + modules <- map Text.unpack <$> m .:? "modules" .!= ["."] + pure Config {..} data ConfigLoadError = ConfigLoadError FilePath ConfigLoadErrorInfo data ConfigLoadErrorInfo - = ConfigParseError ParseException + = ConfigParseError BS.Lazy.ByteString (Pos, String) | SetRootFailed IOError instance PP ConfigLoadError where ppPrec _ (ConfigLoadError path info) = - hang ("Error loading project configuration" <+> text path PP.<.> ":") - 4 (pp info) - -instance PP ConfigLoadErrorInfo where - ppPrec _ (ConfigParseError exn) = - text (prettyPrintParseException exn) - ppPrec _ (SetRootFailed ioe) = - hang "Failed to set project root:" - 4 (text (show ioe)) + case info of + ConfigParseError file (pos, err) -> text $ + show topMsg ++ prettyPosWithSource pos file "\nParse error:" ++ err + SetRootFailed ioe -> + hang topMsg + 4 (hang "Failed to set project root:" + 4 (text (show ioe))) + where + topMsg = "Error loading project configuration" <+> text path PP.<.> ":" loadConfig :: FilePath -> IO (Either ConfigLoadError Config) loadConfig path = do isDir <- doesDirectoryExist path let filePath = if isDir then path FP. "cryproject.yaml" else path - runExceptT $ withExceptT (ConfigLoadError filePath) do - Config {..} <- withExceptT ConfigParseError do - ExceptT (decodeFileEither @ParsedConfig filePath) - <&> \Config {..} -> Config - { root = fromMaybe "." root - , modules = fromMaybe ["."] modules } :: Config - withExceptT SetRootFailed $ ExceptT $ tryIOError $ - setCurrentDirectory (takeDirectory filePath FP. root) - pure Config {..} + -- Use strict IO since we are writing to the same file later + file <- BS.Lazy.fromStrict <$> BS.Strict.readFile filePath + first (ConfigLoadError filePath) <$> + case decode1 file of + Left (pos, err) -> pure $ Left $ ConfigParseError file (pos, err) + Right config -> first SetRootFailed <$> tryIOError do + setCurrentDirectory (takeDirectory filePath FP. root config) + pure config data FullFingerprint = FullFingerprint { moduleFingerprint :: Fingerprint From ccfc450d7fbce7a1979a7c17224c3310dba701c0 Mon Sep 17 00:00:00 2001 From: Iavor Diatchki Date: Mon, 12 Feb 2024 16:07:38 -0800 Subject: [PATCH 12/35] This should be just refactoring and comments. Hopefully, does not change any functionality. --- cryptol-repl-internal/REPL/Haskeline.hs | 13 +- src/Cryptol/Project.hs | 466 +++++++++++++++--------- 2 files changed, 307 insertions(+), 172 deletions(-) diff --git a/cryptol-repl-internal/REPL/Haskeline.hs b/cryptol-repl-internal/REPL/Haskeline.hs index b05ae7b51..7f4bc4760 100644 --- a/cryptol-repl-internal/REPL/Haskeline.hs +++ b/cryptol-repl-internal/REPL/Haskeline.hs @@ -149,13 +149,12 @@ repl cryrc projectConfig replMode callStacks stopOnError begin = replAction = do status <- loadCryRC cryrc - if crSuccess status - then do - begin - case projectConfig of - Just config -> Project.run config - Nothing -> crySession replMode stopOnError - else return status + if crSuccess status then do + begin + case projectConfig of + Just config -> Project.loadProject config + Nothing -> crySession replMode stopOnError + else return status -- | Try to set the history file. setHistoryFile :: Settings REPL -> IO (Settings REPL) diff --git a/src/Cryptol/Project.hs b/src/Cryptol/Project.hs index 4087e4b86..5071e2a1e 100644 --- a/src/Cryptol/Project.hs +++ b/src/Cryptol/Project.hs @@ -3,15 +3,16 @@ {-# LANGUAGE LambdaCase #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE RankNTypes #-} -{-# LANGUAGE RecordWildCards #-} +{-# LANGUAGE NamedFieldPuns #-} module Cryptol.Project ( Config , loadConfig - , run + , loadProject ) where -import Control.Monad (unless, void) +import Control.Monad (unless, void) +import Control.Monad.Reader import Control.Monad.State import Data.Bifunctor import qualified Data.ByteString as BS.Strict @@ -41,15 +42,18 @@ import Cryptol.Utils.Ident import Cryptol.Utils.Logger import Cryptol.Utils.PP as PP +-------------------------------------------------------------------------------- +-- Project Configuration + data Config = Config { root :: FilePath , modules :: [FilePath] } instance FromYAML Config where - parseYAML = withMap "Config" \m -> do - root <- Text.unpack <$> m .:? "root" .!= "." - modules <- map Text.unpack <$> m .:? "modules" .!= ["."] - pure Config {..} + parseYAML = withMap "Config" \m -> + do root <- Text.unpack <$> m .:? "root" .!= "." + modules <- map Text.unpack <$> m .:? "modules" .!= ["."] + pure Config { root, modules } data ConfigLoadError = ConfigLoadError FilePath ConfigLoadErrorInfo @@ -69,6 +73,7 @@ instance PP ConfigLoadError where where topMsg = "Error loading project configuration" <+> text path PP.<.> ":" +-- | Parse project configuration. loadConfig :: FilePath -> IO (Either ConfigLoadError Config) loadConfig path = do isDir <- doesDirectoryExist path @@ -77,16 +82,18 @@ loadConfig path = do file <- BS.Lazy.fromStrict <$> BS.Strict.readFile filePath first (ConfigLoadError filePath) <$> case decode1 file of - Left (pos, err) -> pure $ Left $ ConfigParseError file (pos, err) - Right config -> first SetRootFailed <$> tryIOError do - setCurrentDirectory (takeDirectory filePath FP. root config) - pure config + Left (pos, err) -> pure (Left (ConfigParseError file (pos, err))) + Right config -> + first SetRootFailed <$> + tryIOError + do setCurrentDirectory (takeDirectory filePath FP. root config) + pure config -data FullFingerprint = FullFingerprint - { moduleFingerprint :: Fingerprint - , includeFingerprints :: Map FilePath Fingerprint - , foreignFingerprints :: Set Fingerprint } - deriving (Eq, Show, Read) + +-------------------------------------------------------------------------------- +-- The Loading Monad + +type LoadM = ReaderT LoadConfig (StateT LoadState ModuleM) data ScanStatus = LoadedChanged @@ -96,15 +103,60 @@ data ScanStatus data LoadState = LoadState { findModuleCache :: Map (ModName, [FilePath]) ModulePath - , scanned :: Map ModulePath (FullFingerprint, ScanStatus) } + -- ^ Map (module name, search path) -> module path + + , scanned :: Map ModulePath (FullFingerprint, ScanStatus) + } + +data FullFingerprint = FullFingerprint + { moduleFingerprint :: Fingerprint + , includeFingerprints :: Map FilePath Fingerprint + , foreignFingerprints :: Set Fingerprint } + deriving (Eq, Show, Read) + -type LoadM = StateT LoadState ModuleM +data LoadConfig = LoadConfig + { canonRoot :: FilePath + , loadCache :: LoadCache + } + +doModule :: M.ModuleM a -> LoadM a +doModule m = lift (lift m) + +doIO :: IO a -> LoadM a +doIO m = doModule (M.io m) liftCallback :: (forall a. ModuleM a -> ModuleM a) -> LoadM b -> LoadM b -liftCallback f x = StateT (f . runStateT x) +liftCallback f x = + do r <- ask + s <- get + (a,s1) <- doModule (f (runStateT (runReaderT x r) s)) + put s1 + pure a + +runLoadM :: Config -> LoadM () -> M.ModuleM LoadState +runLoadM cfg m = + do loadCfg <- + M.io + do path <- canonicalizePath (root cfg) + cache <- loadLoadCache + pure LoadConfig { canonRoot = path, loadCache = cache } + let loadState = LoadState { findModuleCache = Map.empty + , scanned = Map.empty + } + execStateT (runReaderT m loadCfg) loadState + +insertScanned :: ModulePath -> FullFingerprint -> ScanStatus -> LoadM () +insertScanned mpath fp status = + modify' \ls -> ls { scanned = Map.insert mpath (fp, status) (scanned ls) } + + +-------------------------------------------------------------------------------- +-- The load cache. This is what persists across invocations. newtype LoadCache = LoadCache - { cacheFingerprints :: Map ModulePath FullFingerprint } + { cacheFingerprints :: Map ModulePath FullFingerprint + } deriving (Show, Read) metaDir, loadCachePath :: FilePath @@ -114,150 +166,234 @@ loadCachePath = metaDir FP. "loadcache" emptyLoadCache :: LoadCache emptyLoadCache = LoadCache { cacheFingerprints = Map.empty } -run :: Config -> REPL CommandResult -run Config {..} = do - canonRoot <- REPL.io $ canonicalizePath root - minp <- getModuleInput - (res, warnings) <- REPL.io $ runModuleM minp do - loadCache <- M.io $ - (fromMaybe emptyLoadCache . readMaybe <$> readFile loadCachePath) - `catchIOError` \_ -> pure emptyLoadCache - let scanFromPath :: FilePath -> LoadM () - scanFromPath fpath = - liftCallback (withPrependedSearchPath [takeDirectory fpath]) do - foundFPath <- lift $ M.findFile fpath - mpath <- lift $ InFile <$> M.io (canonicalizePath foundFPath) - void $ scan Nothing mpath - scan :: Maybe ImportSource -> ModulePath -> LoadM ScanStatus - scan mbIsrc mpath = do - ls <- get - case Map.lookup mpath (scanned ls) of - Just (_, status) -> pure status - Nothing -> liftCallback (errorInFile mpath) do - lift $ withLogger logPutStrLn $ - "Scanning " ++ case mpath of - InFile p -> makeRelative canonRoot p - InMem l _ -> l - (fi, pmDeps) <- lift $ findDepsOf' mpath - foreignFps <- getForeignFps $ Map.keysSet (fiForeignDeps fi) - let newFp = FullFingerprint - { moduleFingerprint = fiFingerprint fi +loadLoadCache :: IO LoadCache +loadLoadCache = + do txt <- readFile loadCachePath + pure (fromMaybe emptyLoadCache (readMaybe txt)) + `catchIOError` \_ -> pure emptyLoadCache + +saveLoadCache :: LoadCache -> IO () +saveLoadCache cache = + do createDirectoryIfMissing False metaDir + writeFile loadCachePath (show cache) + + +-------------------------------------------------------------------------------- + +-- | Load a project. +-- Note that this does not update the Cryptol environment, it only updates +-- the project cache. +-- XXX: we probably want more functionality later on. +loadProject :: Config -> REPL CommandResult +loadProject cfg = + do minp <- getModuleInput + + (res, warnings) <- + REPL.io $ runModuleM minp + do ls <- runLoadM cfg (for_ (modules cfg) loadPath) + M.io $ + saveLoadCache LoadCache { cacheFingerprints = fst <$> scanned ls } + + printModuleWarnings warnings + + case res of + + Left err -> + do names <- mctxNameDisp <$> REPL.getFocusedEnv + rPrint (pp (ModuleSystemError names err)) + pure emptyCommandResult { crSuccess = False } + + Right _ -> + do rPutStrLn "all loaded!" + pure emptyCommandResult + + +-- | Search for .cry files in the given path. +loadPath :: FilePath -> LoadM () +loadPath path = + do isDir <- doIO (doesDirectoryExist path) + if isDir + then + doIO (tryIOError (getDirectoryContents path)) >>= + \case + Left err -> doModule (otherIOError path err) + Right entries -> for_ entries \entry -> loadPath (path FP. entry) + else + case takeExtension path of + ".cry" -> scanFromPath path + _ -> pure () + + +-- | Load a particular file path. +scanFromPath :: FilePath -> LoadM () +scanFromPath fpath = + liftCallback (withPrependedSearchPath [takeDirectory fpath]) + do foundFPath <- doModule (M.findFile fpath) + mpath <- doIO (InFile <$> canonicalizePath foundFPath) + void (scan Nothing mpath) + + +-- | Scan from a particular import source. +scanFromImportSource :: ImportSource -> LoadM ScanStatus +scanFromImportSource isrc = + do mpath <- findModule' isrc + scan (Just isrc) mpath + + +-- | This does the actual scanning work. +scan :: Maybe ImportSource -> ModulePath -> LoadM ScanStatus +scan mbIsrc mpath = + do ls <- get + case Map.lookup mpath (scanned ls) of + Just (_, status) -> pure status + Nothing -> + liftCallback (errorInFile mpath) + do root <- asks canonRoot + + -- XXX: Use the logger from REPL? + doModule $ withLogger logPutStrLn $ + "Scanning " ++ case mpath of + InFile p -> makeRelative root p + InMem l _ -> l + + (fi, pmDeps) <- doModule (findDepsOf' mpath) + foreignFps <- doModule (getForeignFps (fiForeignDeps fi)) + + let newFp = + FullFingerprint + { moduleFingerprint = fiFingerprint fi , includeFingerprints = fiIncludeDeps fi - , foreignFingerprints = foreignFps } - loadChanged = LoadedChanged <$ load mbIsrc mpath - (fiFingerprint fi) (fiIncludeDeps fi) pmDeps - status <- case Map.lookup mpath (cacheFingerprints loadCache) of - Just oldFp - | oldFp == newFp -> do - let currentModNames = map (thing . mName . fst) pmDeps - depStatuses <- traverse scanFromImportSource $ - filter ((`notElem` currentModNames) . importedModule) $ - concatMap snd pmDeps - if LoadedChanged `elem` depStatuses - then loadChanged - else pure NotLoadedNotChanged + , foreignFingerprints = foreignFps + } + + loadChanged = + LoadedChanged <$ + load mbIsrc mpath + (fiFingerprint fi) (fiIncludeDeps fi) pmDeps + + fps <- asks (cacheFingerprints . loadCache) + status <- + case Map.lookup mpath fps of + Just oldFp | oldFp == newFp -> + do let currentModNames = map (thing . mName . fst) pmDeps + depStatuses <- + traverse scanFromImportSource + [ src + | (_,srcs) <- pmDeps + , src <- srcs + , importedModule src `notElem` currentModNames + ] + + if LoadedChanged `elem` depStatuses + then loadChanged + else pure NotLoadedNotChanged _ -> loadChanged - insertScanned mpath newFp status - pure status - scanFromImportSource :: ImportSource -> LoadM ScanStatus - scanFromImportSource isrc = do - mpath <- findModule' isrc - scan (Just isrc) mpath - parseAndLoad :: ImportSource -> ModulePath -> LoadM (Fingerprint, Map FilePath Fingerprint, [FileInfo]) - parseAndLoad isrc mpath = do - (newModFp, newIncFps, pms) <- lift $ parseModule mpath - fis <- load (Just isrc) mpath newModFp newIncFps $ - map (\pm -> let pm' = addPrelude pm in (pm', findDeps pm')) pms - pure (newModFp, newIncFps, fis) - load mbIsrc mpath newModFp newIncFps pmDeps = - for pmDeps \(pm, deps) -> do - let isrc = fromMaybe (FromModule (thing (mName pm))) mbIsrc - liftCallback (loading isrc) do - traverse_ loadFromImportSource deps - lift $ fmap snd $ - doLoadModule True False isrc mpath newModFp newIncFps pm $ - Set.fromList $ map importedModule deps - getForeignFps :: Set FilePath -> LoadM (Set Fingerprint) - getForeignFps fsrcPaths = lift $ - Set.fromList <$> for (Set.toList fsrcPaths) \fsrcPath -> - M.io (fingerprintFile fsrcPath) >>= \case - Left ioe -> otherIOError fsrcPath ioe - Right fp -> pure fp - insertScanned mpath fp status = modify' \ls -> ls - { scanned = Map.insert mpath (fp, status) (scanned ls) } - findModule' :: ImportSource -> LoadM ModulePath - findModule' isrc = do - let mname = modNameToNormalModName $ importedModule isrc - searchPath <- lift M.getSearchPath - ls <- get - case Map.lookup (mname, searchPath) (findModuleCache ls) of - Just mpath -> pure mpath - Nothing -> do - mpath <- lift $ findModule mname >>= \case - InFile path -> InFile <$> M.io (canonicalizePath path) - InMem l c -> pure $ InMem l c - put ls - { findModuleCache = - Map.insert (mname, searchPath) mpath (findModuleCache ls) } - pure mpath - loadFromImportSource :: ImportSource -> LoadM () - loadFromImportSource isrc = do - mpath <- findModule' isrc - liftCallback (errorInFile mpath) do - ls' <- get - case Map.lookup mpath (scanned ls') of - Just (fp, status) -> - case status of - LoadedChanged -> pure () - LoadedNotChanged -> pure () - NotLoadedNotChanged -> do - loaded <- lift $ M.isLoadedStrict (importedModule isrc) mpath - unless loaded do - _ <- parseAndLoad isrc mpath - insertScanned mpath fp LoadedNotChanged - Nothing -> do - -- The file has not been fully loaded yet, but the individual - -- module within the file might - loaded <- lift $ M.isLoadedStrict (importedModule isrc) mpath - unless loaded do - (newModFp, newIncFps, fis) <- parseAndLoad isrc mpath - foreignFps <- getForeignFps $ - Set.unions $ map (Map.keysSet . fiForeignDeps) fis - let newFp = FullFingerprint - { moduleFingerprint = newModFp - , includeFingerprints = newIncFps - , foreignFingerprints = foreignFps } - insertScanned mpath newFp - case Map.lookup mpath (cacheFingerprints loadCache) of - Just oldFp - | oldFp == newFp -> LoadedNotChanged - _ -> LoadedChanged - ls <- flip execStateT - LoadState { findModuleCache = Map.empty, scanned = Map.empty } $ - for_ modules \p -> do - let loadPath path = do - isDir <- lift $ M.io $ doesDirectoryExist path - if isDir - then lift (M.io (tryIOError (listDirectory path))) >>= \case - Left err -> lift $ otherIOError path err - Right entries -> for_ entries \case - '.':_ -> pure () - entry -> loadPath (path FP. entry) - else case takeExtension path of - ".cry" -> scanFromPath path - _ -> pure () - loadPath p - let newLoadCache = LoadCache - { cacheFingerprints = Map.map fst (scanned ls) } - M.io do - createDirectoryIfMissing False metaDir - writeFile loadCachePath $ show newLoadCache - printModuleWarnings warnings - case res of - Left err -> do - names <- mctxNameDisp <$> REPL.getFocusedEnv - rPrint $ pp $ ModuleSystemError names err - pure emptyCommandResult { crSuccess = False } - Right _ -> do - rPutStrLn "all loaded!" - pure emptyCommandResult + + insertScanned mpath newFp status + pure status + + + +parseAndLoad :: + ImportSource -> + ModulePath -> + LoadM (Fingerprint, Map FilePath Fingerprint, [FileInfo]) +parseAndLoad isrc mpath = + do (newModFp, newIncFps, pms) <- doModule (parseModule mpath) + fis <- load (Just isrc) mpath newModFp newIncFps + [ (pm', findDeps pm') + | pm <- pms + , let pm' = addPrelude pm + ] + pure (newModFp, newIncFps, fis) + + + +{- | Process stuff we parsed from a file. +The reason we have a list of modules here, rather than just one, +is that a single file may contain multiple modules, due to to desugaring +of various things in the module system. -} +load :: + Maybe ImportSource -> + ModulePath -> + Fingerprint -> + Map FilePath Fingerprint -> + [(ModuleG ModName PName, [ImportSource])] -> + LoadM [FileInfo] +load mbIsrc mpath newModFp newIncFps pmDeps = + for pmDeps \(pm, deps) -> + do let isrc = fromMaybe (FromModule (thing (mName pm))) mbIsrc + liftCallback (loading isrc) + do traverse_ loadFromImportSource deps + doModule $ fmap snd $ + doLoadModule True False isrc mpath newModFp newIncFps pm $ + Set.fromList (map importedModule deps) + +loadFromImportSource :: ImportSource -> LoadM () +loadFromImportSource isrc = + do mpath <- findModule' isrc + let unlessLoaded k = + do loaded <- doModule (M.isLoadedStrict (importedModule isrc) mpath) + unless loaded k + + liftCallback (errorInFile mpath) + do ls' <- get + case Map.lookup mpath (scanned ls') of + Just (fp, status) -> + case status of + LoadedChanged -> pure () + LoadedNotChanged -> pure () + NotLoadedNotChanged -> + unlessLoaded + do _ <- parseAndLoad isrc mpath + insertScanned mpath fp LoadedNotChanged + + -- The file has not been fully loaded yet, but the individual + -- module within the file might + Nothing -> + unlessLoaded + do (newModFp, newIncFps, fis) <- parseAndLoad isrc mpath + foreignFps <- doModule $ getForeignFps $ + Map.unionsWith (||) (map fiForeignDeps fis) + let newFp = FullFingerprint + { moduleFingerprint = newModFp + , includeFingerprints = newIncFps + , foreignFingerprints = foreignFps + } + fps <- asks (cacheFingerprints . loadCache) + insertScanned mpath newFp + case Map.lookup mpath fps of + Just oldFp | oldFp == newFp -> LoadedNotChanged + _ -> LoadedChanged + + +-- | Module path for the given import +findModule' :: ImportSource -> LoadM ModulePath +findModule' isrc = + do let mname = modNameToNormalModName (importedModule isrc) + searchPath <- doModule M.getSearchPath + ls <- get + case Map.lookup (mname, searchPath) (findModuleCache ls) of + Just mpath -> pure mpath + Nothing -> + do modLoc <- doModule (findModule mname) + mpath <- case modLoc of + InFile path -> InFile <$> doIO (canonicalizePath path) + InMem l c -> pure (InMem l c) + put ls { findModuleCache = Map.insert (mname, searchPath) + mpath (findModuleCache ls) } + pure mpath + + +-- | Fingerprints of foreign declarations +getForeignFps :: Map FilePath Bool -> M.ModuleM (Set Fingerprint) +getForeignFps fsrcPaths = + Set.fromList <$> + for (Map.keys fsrcPaths) \fsrcPath -> + M.io (fingerprintFile fsrcPath) >>= + \case + Left ioe -> otherIOError fsrcPath ioe + Right fp -> pure fp + + + From 141e60b01332e8c77447a75fa196add67f2a7853 Mon Sep 17 00:00:00 2001 From: Eric Mertens Date: Fri, 1 Nov 2024 11:34:09 -0700 Subject: [PATCH 13/35] fixup test results --- tests/issues/T146.icry.stdout | 4 ++-- tests/regression/tc-errors.icry.stdout | 2 +- tests/suiteb/ECDSAKeyPair.icry.stdout | 4 ---- tests/suiteb/ECDSASigGen.icry.stdout | 2 -- tests/suiteb/ECDSASigVerify.icry.stdout | 2 -- 5 files changed, 3 insertions(+), 11 deletions(-) diff --git a/tests/issues/T146.icry.stdout b/tests/issues/T146.icry.stdout index d189b790b..3b264dba3 100644 --- a/tests/issues/T146.icry.stdout +++ b/tests/issues/T146.icry.stdout @@ -8,11 +8,11 @@ Loading module Main When checking signature variable 'fv' where ?b is type argument 'fv' of 'Main::ec_v2' at T146.cry:5:19--5:24 - fv`902 is signature variable 'fv' at T146.cry:11:10--11:12 + fv`895 is signature variable 'fv' at T146.cry:11:10--11:12 [error] at T146.cry:12:11--12:21: The type ?a is not sufficiently polymorphic. It cannot depend on quantified variables: fv`895 When checking type of field 'v0' where ?a is type argument 'fv' of 'Main::ec_v1' at T146.cry:4:19--4:24 - fv`902 is signature variable 'fv' at T146.cry:11:10--11:12 + fv`895 is signature variable 'fv' at T146.cry:11:10--11:12 diff --git a/tests/regression/tc-errors.icry.stdout b/tests/regression/tc-errors.icry.stdout index e5e8135ed..0eee36930 100644 --- a/tests/regression/tc-errors.icry.stdout +++ b/tests/regression/tc-errors.icry.stdout @@ -51,7 +51,7 @@ Loading module Main Loading module Cryptol Loading module Main -[error] Invalid recursive dependency: +[error] Invalid self dependency: • type Main::T, defined at 1:6--1:7 Loading module Cryptol Loading module Main diff --git a/tests/suiteb/ECDSAKeyPair.icry.stdout b/tests/suiteb/ECDSAKeyPair.icry.stdout index 725fc4c46..9486087a5 100644 --- a/tests/suiteb/ECDSAKeyPair.icry.stdout +++ b/tests/suiteb/ECDSAKeyPair.icry.stdout @@ -2,10 +2,6 @@ Loading module Cryptol Loading module Cryptol Loading module PrimeEC Loading module NISTCurves -Loading module Main -property p192_keypair_test Using exhaustive testing. -Testing... Passed 1 tests. -Q.E.D. property p192_valid_curve Using exhaustive testing. Testing... Passed 1 tests. Q.E.D. diff --git a/tests/suiteb/ECDSASigGen.icry.stdout b/tests/suiteb/ECDSASigGen.icry.stdout index 992830bcf..64d78e0c1 100644 --- a/tests/suiteb/ECDSASigGen.icry.stdout +++ b/tests/suiteb/ECDSASigGen.icry.stdout @@ -2,8 +2,6 @@ Loading module Cryptol Loading module Cryptol Loading module PrimeEC Loading module NISTCurves -Loading module SuiteB -Loading module Main property p192_valid_curve Using exhaustive testing. Testing... Passed 1 tests. Q.E.D. diff --git a/tests/suiteb/ECDSASigVerify.icry.stdout b/tests/suiteb/ECDSASigVerify.icry.stdout index b6100ef4d..14ec1ef26 100644 --- a/tests/suiteb/ECDSASigVerify.icry.stdout +++ b/tests/suiteb/ECDSASigVerify.icry.stdout @@ -2,8 +2,6 @@ Loading module Cryptol Loading module Cryptol Loading module PrimeEC Loading module NISTCurves -Loading module SuiteB -Loading module Main property p192_valid_curve Using exhaustive testing. Testing... Passed 1 tests. Q.E.D. From 136cf543f53d1c5b06f0d1f7060e408bfa8c164d Mon Sep 17 00:00:00 2001 From: Iavor Diatchki Date: Tue, 13 Feb 2024 11:39:08 -0800 Subject: [PATCH 14/35] More refactoring. There should be no semantic changes here. --- cryptol-repl-internal/REPL/Haskeline.hs | 2 +- cryptol.cabal | 3 + src/Cryptol/Project.hs | 226 ++++-------------------- src/Cryptol/Project/Cache.hs | 50 ++++++ src/Cryptol/Project/Config.hs | 62 +++++++ src/Cryptol/Project/Monad.hs | 139 +++++++++++++++ 6 files changed, 285 insertions(+), 197 deletions(-) create mode 100644 src/Cryptol/Project/Cache.hs create mode 100644 src/Cryptol/Project/Config.hs create mode 100644 src/Cryptol/Project/Monad.hs diff --git a/cryptol-repl-internal/REPL/Haskeline.hs b/cryptol-repl-internal/REPL/Haskeline.hs index 7f4bc4760..134a17a13 100644 --- a/cryptol-repl-internal/REPL/Haskeline.hs +++ b/cryptol-repl-internal/REPL/Haskeline.hs @@ -152,7 +152,7 @@ repl cryrc projectConfig replMode callStacks stopOnError begin = if crSuccess status then do begin case projectConfig of - Just config -> Project.loadProject config + Just config -> Project.loadProjectREPL config Nothing -> crySession replMode stopOnError else return status diff --git a/cryptol.cabal b/cryptol.cabal index c20de921b..57999af1a 100644 --- a/cryptol.cabal +++ b/cryptol.cabal @@ -243,6 +243,9 @@ library Cryptol.REPL.Trie, Cryptol.Project + Cryptol.Project.Config + Cryptol.Project.Monad + Cryptol.Project.Cache Other-modules: Cryptol.Parser.LexerUtils, Cryptol.Parser.ParserUtils, diff --git a/src/Cryptol/Project.hs b/src/Cryptol/Project.hs index 5071e2a1e..83246e751 100644 --- a/src/Cryptol/Project.hs +++ b/src/Cryptol/Project.hs @@ -1,35 +1,25 @@ {-# LANGUAGE BlockArguments #-} -{-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE LambdaCase #-} -{-# LANGUAGE OverloadedStrings #-} -{-# LANGUAGE RankNTypes #-} -{-# LANGUAGE NamedFieldPuns #-} module Cryptol.Project - ( Config + ( Config(..) , loadConfig + , ScanStatus(..) , loadProject + , loadProjectREPL ) where -import Control.Monad (unless, void) -import Control.Monad.Reader -import Control.Monad.State -import Data.Bifunctor -import qualified Data.ByteString as BS.Strict -import qualified Data.ByteString.Lazy as BS.Lazy +import Control.Monad (void,unless) import Data.Foldable import Data.Map.Strict (Map) import qualified Data.Map.Strict as Map import Data.Maybe import Data.Set (Set) import qualified Data.Set as Set -import qualified Data.Text as Text import Data.Traversable -import Data.YAML import System.Directory import System.FilePath as FP import System.IO.Error -import Text.Read (readMaybe) import Cryptol.ModuleSystem.Base as M import Cryptol.ModuleSystem.Env @@ -38,166 +28,23 @@ import Cryptol.ModuleSystem.Monad as M import Cryptol.Parser.AST import Cryptol.REPL.Command import Cryptol.REPL.Monad as REPL -import Cryptol.Utils.Ident import Cryptol.Utils.Logger import Cryptol.Utils.PP as PP +import Cryptol.Project.Config +import Cryptol.Project.Cache +import Cryptol.Project.Monad --------------------------------------------------------------------------------- --- Project Configuration - -data Config = Config - { root :: FilePath - , modules :: [FilePath] } - -instance FromYAML Config where - parseYAML = withMap "Config" \m -> - do root <- Text.unpack <$> m .:? "root" .!= "." - modules <- map Text.unpack <$> m .:? "modules" .!= ["."] - pure Config { root, modules } - -data ConfigLoadError = ConfigLoadError FilePath ConfigLoadErrorInfo - -data ConfigLoadErrorInfo - = ConfigParseError BS.Lazy.ByteString (Pos, String) - | SetRootFailed IOError - -instance PP ConfigLoadError where - ppPrec _ (ConfigLoadError path info) = - case info of - ConfigParseError file (pos, err) -> text $ - show topMsg ++ prettyPosWithSource pos file "\nParse error:" ++ err - SetRootFailed ioe -> - hang topMsg - 4 (hang "Failed to set project root:" - 4 (text (show ioe))) - where - topMsg = "Error loading project configuration" <+> text path PP.<.> ":" - --- | Parse project configuration. -loadConfig :: FilePath -> IO (Either ConfigLoadError Config) -loadConfig path = do - isDir <- doesDirectoryExist path - let filePath = if isDir then path FP. "cryproject.yaml" else path - -- Use strict IO since we are writing to the same file later - file <- BS.Lazy.fromStrict <$> BS.Strict.readFile filePath - first (ConfigLoadError filePath) <$> - case decode1 file of - Left (pos, err) -> pure (Left (ConfigParseError file (pos, err))) - Right config -> - first SetRootFailed <$> - tryIOError - do setCurrentDirectory (takeDirectory filePath FP. root config) - pure config - - --------------------------------------------------------------------------------- --- The Loading Monad - -type LoadM = ReaderT LoadConfig (StateT LoadState ModuleM) - -data ScanStatus - = LoadedChanged - | LoadedNotChanged - | NotLoadedNotChanged - deriving Eq - -data LoadState = LoadState - { findModuleCache :: Map (ModName, [FilePath]) ModulePath - -- ^ Map (module name, search path) -> module path - - , scanned :: Map ModulePath (FullFingerprint, ScanStatus) - } - -data FullFingerprint = FullFingerprint - { moduleFingerprint :: Fingerprint - , includeFingerprints :: Map FilePath Fingerprint - , foreignFingerprints :: Set Fingerprint } - deriving (Eq, Show, Read) - - -data LoadConfig = LoadConfig - { canonRoot :: FilePath - , loadCache :: LoadCache - } - -doModule :: M.ModuleM a -> LoadM a -doModule m = lift (lift m) - -doIO :: IO a -> LoadM a -doIO m = doModule (M.io m) - -liftCallback :: (forall a. ModuleM a -> ModuleM a) -> LoadM b -> LoadM b -liftCallback f x = - do r <- ask - s <- get - (a,s1) <- doModule (f (runStateT (runReaderT x r) s)) - put s1 - pure a - -runLoadM :: Config -> LoadM () -> M.ModuleM LoadState -runLoadM cfg m = - do loadCfg <- - M.io - do path <- canonicalizePath (root cfg) - cache <- loadLoadCache - pure LoadConfig { canonRoot = path, loadCache = cache } - let loadState = LoadState { findModuleCache = Map.empty - , scanned = Map.empty - } - execStateT (runReaderT m loadCfg) loadState - -insertScanned :: ModulePath -> FullFingerprint -> ScanStatus -> LoadM () -insertScanned mpath fp status = - modify' \ls -> ls { scanned = Map.insert mpath (fp, status) (scanned ls) } - - --------------------------------------------------------------------------------- --- The load cache. This is what persists across invocations. - -newtype LoadCache = LoadCache - { cacheFingerprints :: Map ModulePath FullFingerprint - } - deriving (Show, Read) - -metaDir, loadCachePath :: FilePath -metaDir = ".cryproject" -loadCachePath = metaDir FP. "loadcache" - -emptyLoadCache :: LoadCache -emptyLoadCache = LoadCache { cacheFingerprints = Map.empty } - -loadLoadCache :: IO LoadCache -loadLoadCache = - do txt <- readFile loadCachePath - pure (fromMaybe emptyLoadCache (readMaybe txt)) - `catchIOError` \_ -> pure emptyLoadCache - -saveLoadCache :: LoadCache -> IO () -saveLoadCache cache = - do createDirectoryIfMissing False metaDir - writeFile loadCachePath (show cache) - - --------------------------------------------------------------------------------- -- | Load a project. -- Note that this does not update the Cryptol environment, it only updates -- the project cache. --- XXX: we probably want more functionality later on. -loadProject :: Config -> REPL CommandResult -loadProject cfg = +-- XXX: Probably should move this in REPL +loadProjectREPL :: Config -> REPL CommandResult +loadProjectREPL cfg = do minp <- getModuleInput - - (res, warnings) <- - REPL.io $ runModuleM minp - do ls <- runLoadM cfg (for_ (modules cfg) loadPath) - M.io $ - saveLoadCache LoadCache { cacheFingerprints = fst <$> scanned ls } - + (res, warnings) <- REPL.io $ runModuleM minp $ loadProject cfg printModuleWarnings warnings - case res of - Left err -> do names <- mctxNameDisp <$> REPL.getFocusedEnv rPrint (pp (ModuleSystemError names err)) @@ -208,6 +55,15 @@ loadProject cfg = pure emptyCommandResult +-- | Load a project. +-- Returns information about the modules that are part of the project. +loadProject :: Config -> M.ModuleM (Map ModulePath ScanStatus) +loadProject cfg = + do info <- runLoadM cfg (for_ (modules cfg) loadPath) + let cache = LoadCache { cacheFingerprints = fst <$> info } + M.io (saveLoadCache cache) + pure (snd <$> info) + -- | Search for .cry files in the given path. loadPath :: FilePath -> LoadM () loadPath path = @@ -243,18 +99,15 @@ scanFromImportSource isrc = -- | This does the actual scanning work. scan :: Maybe ImportSource -> ModulePath -> LoadM ScanStatus scan mbIsrc mpath = - do ls <- get - case Map.lookup mpath (scanned ls) of + do mbStat <- getStatus mpath + case mbStat of Just (_, status) -> pure status Nothing -> liftCallback (errorInFile mpath) - do root <- asks canonRoot + do lab <- getModulePathLabel mpath -- XXX: Use the logger from REPL? - doModule $ withLogger logPutStrLn $ - "Scanning " ++ case mpath of - InFile p -> makeRelative root p - InMem l _ -> l + doModule (withLogger logPutStrLn ("Scanning " ++ lab)) (fi, pmDeps) <- doModule (findDepsOf' mpath) foreignFps <- doModule (getForeignFps (fiForeignDeps fi)) @@ -271,9 +124,9 @@ scan mbIsrc mpath = load mbIsrc mpath (fiFingerprint fi) (fiIncludeDeps fi) pmDeps - fps <- asks (cacheFingerprints . loadCache) + mbOldFP <- getCachedFingerprint mpath status <- - case Map.lookup mpath fps of + case mbOldFP of Just oldFp | oldFp == newFp -> do let currentModNames = map (thing . mName . fst) pmDeps depStatuses <- @@ -337,8 +190,8 @@ loadFromImportSource isrc = unless loaded k liftCallback (errorInFile mpath) - do ls' <- get - case Map.lookup mpath (scanned ls') of + do mbScanned <- getStatus mpath + case mbScanned of Just (fp, status) -> case status of LoadedChanged -> pure () @@ -360,31 +213,12 @@ loadFromImportSource isrc = , includeFingerprints = newIncFps , foreignFingerprints = foreignFps } - fps <- asks (cacheFingerprints . loadCache) + mbOldFP <- getCachedFingerprint mpath insertScanned mpath newFp - case Map.lookup mpath fps of + case mbOldFP of Just oldFp | oldFp == newFp -> LoadedNotChanged _ -> LoadedChanged - --- | Module path for the given import -findModule' :: ImportSource -> LoadM ModulePath -findModule' isrc = - do let mname = modNameToNormalModName (importedModule isrc) - searchPath <- doModule M.getSearchPath - ls <- get - case Map.lookup (mname, searchPath) (findModuleCache ls) of - Just mpath -> pure mpath - Nothing -> - do modLoc <- doModule (findModule mname) - mpath <- case modLoc of - InFile path -> InFile <$> doIO (canonicalizePath path) - InMem l c -> pure (InMem l c) - put ls { findModuleCache = Map.insert (mname, searchPath) - mpath (findModuleCache ls) } - pure mpath - - -- | Fingerprints of foreign declarations getForeignFps :: Map FilePath Bool -> M.ModuleM (Set Fingerprint) getForeignFps fsrcPaths = diff --git a/src/Cryptol/Project/Cache.hs b/src/Cryptol/Project/Cache.hs new file mode 100644 index 000000000..d96ff60e6 --- /dev/null +++ b/src/Cryptol/Project/Cache.hs @@ -0,0 +1,50 @@ +module Cryptol.Project.Cache where + +import Data.Map.Strict (Map) +import qualified Data.Map.Strict as Map +import Data.Set (Set) +import Data.Maybe (fromMaybe) +import System.Directory +import System.FilePath as FP +import System.IO.Error +import Text.Read (readMaybe) + +import Cryptol.ModuleSystem.Env +import Cryptol.ModuleSystem.Fingerprint + +-- | The load cache. This is what persists across invocations. +newtype LoadCache = LoadCache + { cacheFingerprints :: Map ModulePath FullFingerprint + } + deriving (Show, Read) + + +-- | The full fingerprint hashes the module, but +-- also the contents of included files and foreign libraries. +data FullFingerprint = FullFingerprint + { moduleFingerprint :: Fingerprint + , includeFingerprints :: Map FilePath Fingerprint + , foreignFingerprints :: Set Fingerprint + } + deriving (Eq, Show, Read) + +-- XXX: This should probably be a parameter +metaDir, loadCachePath :: FilePath +metaDir = ".cryproject" +loadCachePath = metaDir FP. "loadcache" + +emptyLoadCache :: LoadCache +emptyLoadCache = LoadCache { cacheFingerprints = Map.empty } + +loadLoadCache :: IO LoadCache +loadLoadCache = + do txt <- readFile loadCachePath + pure (fromMaybe emptyLoadCache (readMaybe txt)) + `catchIOError` \_ -> pure emptyLoadCache + +saveLoadCache :: LoadCache -> IO () +saveLoadCache cache = + do createDirectoryIfMissing False metaDir + writeFile loadCachePath (show cache) + + diff --git a/src/Cryptol/Project/Config.hs b/src/Cryptol/Project/Config.hs new file mode 100644 index 000000000..7374ea965 --- /dev/null +++ b/src/Cryptol/Project/Config.hs @@ -0,0 +1,62 @@ +{-# LANGUAGE BlockArguments #-} +{-# LANGUAGE NamedFieldPuns #-} +{-# LANGUAGE OverloadedStrings #-} +module Cryptol.Project.Config where + +import qualified Data.Text as Text +import Data.YAML +import qualified Data.ByteString as BS.Strict +import qualified Data.ByteString.Lazy as BS.Lazy +import Data.Bifunctor (first) +import System.Directory +import System.FilePath as FP +import System.IO.Error + +import Cryptol.Utils.PP as PP + +data Config = Config + { root :: FilePath + , modules :: [FilePath] + } + +instance FromYAML Config where + parseYAML = withMap "Config" \m -> + do root <- Text.unpack <$> m .:? "root" .!= "." + modules <- map Text.unpack <$> m .:? "modules" .!= ["."] + pure Config { root, modules } + +data ConfigLoadError = ConfigLoadError FilePath ConfigLoadErrorInfo + +data ConfigLoadErrorInfo + = ConfigParseError BS.Lazy.ByteString (Pos, String) + | SetRootFailed IOError + +instance PP ConfigLoadError where + ppPrec _ (ConfigLoadError path info) = + case info of + ConfigParseError file (pos, err) -> text $ + show topMsg ++ prettyPosWithSource pos file "\nParse error:" ++ err + SetRootFailed ioe -> + hang topMsg + 4 (hang "Failed to set project root:" + 4 (text (show ioe))) + where + topMsg = "Error loading project configuration" <+> text path PP.<.> ":" + +-- | Parse project configuration. +loadConfig :: FilePath -> IO (Either ConfigLoadError Config) +loadConfig path = do + isDir <- doesDirectoryExist path + let filePath = if isDir then path FP. "cryproject.yaml" else path + -- Use strict IO since we are writing to the same file later + file <- BS.Lazy.fromStrict <$> BS.Strict.readFile filePath + first (ConfigLoadError filePath) <$> + case decode1 file of + Left (pos, err) -> pure (Left (ConfigParseError file (pos, err))) + Right config -> + first SetRootFailed <$> + tryIOError + do setCurrentDirectory (takeDirectory filePath FP. root config) + pure config + + diff --git a/src/Cryptol/Project/Monad.hs b/src/Cryptol/Project/Monad.hs new file mode 100644 index 000000000..23a3d17f6 --- /dev/null +++ b/src/Cryptol/Project/Monad.hs @@ -0,0 +1,139 @@ +{-# LANGUAGE BlockArguments #-} +{-# LANGUAGE RankNTypes #-} +{-# LANGUAGE GeneralizedNewtypeDeriving #-} +module Cryptol.Project.Monad + ( LoadM + , ScanStatus(..) + , runLoadM + , doModule + , doIO + , liftCallback + , insertScanned + , getModulePathLabel + , getCachedFingerprint + , findModule' + , getStatus + ) where + +import Data.Map.Strict (Map) +import qualified Data.Map.Strict as Map +import Control.Monad.Reader +import Control.Monad.State +import System.Directory +import System.FilePath (makeRelative) + +import Cryptol.Utils.Ident +import Cryptol.ModuleSystem.Base as M +import Cryptol.ModuleSystem.Monad as M +import Cryptol.ModuleSystem.Env + +import Cryptol.Project.Config +import Cryptol.Project.Cache + +newtype LoadM a = LoadM (ReaderT LoadConfig (StateT LoadState ModuleM) a) + deriving (Functor,Applicative,Monad) + +data ScanStatus + = LoadedChanged + -- ^ The module is loaded and has changed + + | LoadedNotChanged + -- ^ The module is loaded but did not change + -- This may happen because it is a dependency of something the did change + + | NotLoadedNotChanged + -- ^ The module is not loaded and did not change + deriving Eq + +data LoadState = LoadState + { findModuleCache :: Map (ModName, [FilePath]) ModulePath + -- ^ Map (module name, search path) -> module path + + , scanned :: Map ModulePath (FullFingerprint, ScanStatus) + -- ^ Information about the proccessed modules. + } + +-- | Information about the current project. +data LoadConfig = LoadConfig + { canonRoot :: FilePath + -- ^ Path to the project root, cannoicalized. + + , loadCache :: LoadCache + -- ^ The state of the cache before we started loading the project. + + } + + +-- | Do an operation in the module monad. +doModule :: M.ModuleM a -> LoadM a +doModule m = LoadM (lift (lift m)) + +-- | Do an operation in the IO monad +doIO :: IO a -> LoadM a +doIO m = doModule (M.io m) + +-- | Lift a module level operation to the LoadM monad. +liftCallback :: (forall a. ModuleM a -> ModuleM a) -> LoadM b -> LoadM b +liftCallback f (LoadM m) = + do r <- LoadM ask + s <- LoadM get + (a,s1) <- doModule (f (runStateT (runReaderT m r) s)) + LoadM (put s1) + pure a + +-- | Run a LoadM computation using the given configuration. +runLoadM :: + Config -> LoadM () -> M.ModuleM (Map ModulePath (FullFingerprint, ScanStatus)) +runLoadM cfg (LoadM m) = + do loadCfg <- + M.io + do path <- canonicalizePath (root cfg) + cache <- loadLoadCache + pure LoadConfig { canonRoot = path, loadCache = cache } + let loadState = LoadState { findModuleCache = Map.empty + , scanned = Map.empty + } + scanned <$> execStateT (runReaderT m loadCfg) loadState + +-- | Add information about the status of a module path. +insertScanned :: ModulePath -> FullFingerprint -> ScanStatus -> LoadM () +insertScanned mpath fp status = + LoadM + (modify' \ls -> ls { scanned = Map.insert mpath (fp, status) (scanned ls) }) + + +-- | Get a lab for the given module path. +-- Typically used for output. +getModulePathLabel :: ModulePath -> LoadM String +getModulePathLabel mpath = + case mpath of + InFile p -> LoadM (asks ((`makeRelative` p) . canonRoot)) + InMem l _ -> pure l + + +-- | Get the fingerprint for the given module path. +getCachedFingerprint :: ModulePath -> LoadM (Maybe FullFingerprint) +getCachedFingerprint mpath = + LoadM (asks (Map.lookup mpath . cacheFingerprints . loadCache)) + + +-- | Module path for the given import +findModule' :: ImportSource -> LoadM ModulePath +findModule' isrc = + do ls <- LoadM get + let mname = modNameToNormalModName (importedModule isrc) + searchPath <- doModule M.getSearchPath + case Map.lookup (mname, searchPath) (findModuleCache ls) of + Just mpath -> pure mpath + Nothing -> + do modLoc <- doModule (findModule mname) + mpath <- case modLoc of + InFile path -> InFile <$> doIO (canonicalizePath path) + InMem l c -> pure (InMem l c) + LoadM $ put ls { findModuleCache = Map.insert (mname, searchPath) + mpath (findModuleCache ls) } + pure mpath + +-- | Check if the given file has beein processed. +getStatus :: ModulePath -> LoadM (Maybe (FullFingerprint, ScanStatus)) +getStatus mpath = LoadM (gets (Map.lookup mpath . scanned)) From 0a3e69dd37ace492106d5a098a13160f6b33273c Mon Sep 17 00:00:00 2001 From: Iavor Diatchki Date: Tue, 13 Feb 2024 13:28:21 -0800 Subject: [PATCH 15/35] Comments and wibbles --- src/Cryptol/ModuleSystem/Base.hs | 13 ++++-- src/Cryptol/ModuleSystem/Env.hs | 3 +- src/Cryptol/Project.hs | 71 +++++++++++++++++++------------- src/Cryptol/Project/Monad.hs | 2 +- 4 files changed, 54 insertions(+), 35 deletions(-) diff --git a/src/Cryptol/ModuleSystem/Base.hs b/src/Cryptol/ModuleSystem/Base.hs index c9aa645dc..a0df5096b 100644 --- a/src/Cryptol/ModuleSystem/Base.hs +++ b/src/Cryptol/ModuleSystem/Base.hs @@ -12,8 +12,8 @@ {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE ImplicitParams #-} {-# LANGUAGE LambdaCase #-} -{-# LANGUAGE RecordWildCards #-} {-# LANGUAGE OverloadedStrings #-} +{-# Language DisambiguateRecordFields #-} {-# LANGUAGE BlockArguments #-} module Cryptol.ModuleSystem.Base where @@ -487,12 +487,17 @@ findDepsOf mpath' = do mpath <- case mpath' of InFile file -> InFile <$> io (canonicalizePath file) InMem {} -> pure mpath' - (fi, _) <- findDepsOf' mpath + (fi, _) <- parseWithDeps mpath pure (mpath, fi) -findDepsOf' :: ModulePath -> +{- | Parse the given module path and find its dependencies. +The reason we return a list here, is that sometime files may +contain multiple modules (e.g., due to desugaring `parameter` blocks +in functors. -} +parseWithDeps :: + ModulePath -> ModuleM (FileInfo, [(Module PName, [ImportSource])]) -findDepsOf' mpath = +parseWithDeps mpath = do (fp, incs, ms) <- parseModule mpath let ms' = map addPrelude ms depss = map findDeps' ms' diff --git a/src/Cryptol/ModuleSystem/Env.hs b/src/Cryptol/ModuleSystem/Env.hs index 340ab3d93..db5e4d114 100644 --- a/src/Cryptol/ModuleSystem/Env.hs +++ b/src/Cryptol/ModuleSystem/Env.hs @@ -660,7 +660,8 @@ data FileInfo = FileInfo { fiFingerprint :: Fingerprint , fiIncludeDeps :: Map FilePath Fingerprint , fiImportDeps :: Set ModName - , fiForeignDeps :: Map FilePath Bool -- ^ Foreign dependencies and whether or not they currently exist + , fiForeignDeps :: Map FilePath Bool + -- ^ The bool indicates if the library for the foreign import exists. } deriving (Show,Generic,NFData) diff --git a/src/Cryptol/Project.hs b/src/Cryptol/Project.hs index 83246e751..320792764 100644 --- a/src/Cryptol/Project.hs +++ b/src/Cryptol/Project.hs @@ -59,28 +59,38 @@ loadProjectREPL cfg = -- Returns information about the modules that are part of the project. loadProject :: Config -> M.ModuleM (Map ModulePath ScanStatus) loadProject cfg = - do info <- runLoadM cfg (for_ (modules cfg) loadPath) + do info <- runLoadM cfg (for_ (modules cfg) scanPath) let cache = LoadCache { cacheFingerprints = fst <$> info } M.io (saveLoadCache cache) pure (snd <$> info) --- | Search for .cry files in the given path. -loadPath :: FilePath -> LoadM () -loadPath path = +{- NOTE: +In the functions below: + * "scan" refers to processing a module, but not necesserily loading it, + * "load" means that we are actually loading the module. +-} + + + +-- | Process all .cry files in the given path. +scanPath :: FilePath -> LoadM () +scanPath path = do isDir <- doIO (doesDirectoryExist path) if isDir then doIO (tryIOError (getDirectoryContents path)) >>= \case Left err -> doModule (otherIOError path err) - Right entries -> for_ entries \entry -> loadPath (path FP. entry) + Right entries -> for_ entries \entry -> scanPath (path FP. entry) else + -- XXX: This should probably handle other extenions + -- (literate Cryptol) case takeExtension path of ".cry" -> scanFromPath path _ -> pure () --- | Load a particular file path. +-- | Process a particular file path. scanFromPath :: FilePath -> LoadM () scanFromPath fpath = liftCallback (withPrependedSearchPath [takeDirectory fpath]) @@ -89,14 +99,14 @@ scanFromPath fpath = void (scan Nothing mpath) --- | Scan from a particular import source. +-- | Process a particular import source. scanFromImportSource :: ImportSource -> LoadM ScanStatus scanFromImportSource isrc = do mpath <- findModule' isrc scan (Just isrc) mpath --- | This does the actual scanning work. +-- | Process the given module, and return information about what happened. scan :: Maybe ImportSource -> ModulePath -> LoadM ScanStatus scan mbIsrc mpath = do mbStat <- getStatus mpath @@ -106,11 +116,12 @@ scan mbIsrc mpath = liftCallback (errorInFile mpath) do lab <- getModulePathLabel mpath - -- XXX: Use the logger from REPL? - doModule (withLogger logPutStrLn ("Scanning " ++ lab)) - - (fi, pmDeps) <- doModule (findDepsOf' mpath) - foreignFps <- doModule (getForeignFps (fiForeignDeps fi)) + (fi, parsed, foreignFps) <- + doModule + do withLogger logPutStrLn ("Scanning " ++ lab) + (fi, parsed) <- parseWithDeps mpath + foreignFps <- getForeignFps (fiForeignDeps fi) + pure (fi, parsed, foreignFps) let newFp = FullFingerprint @@ -122,19 +133,19 @@ scan mbIsrc mpath = loadChanged = LoadedChanged <$ load mbIsrc mpath - (fiFingerprint fi) (fiIncludeDeps fi) pmDeps + (fiFingerprint fi) (fiIncludeDeps fi) parsed mbOldFP <- getCachedFingerprint mpath status <- case mbOldFP of Just oldFp | oldFp == newFp -> - do let currentModNames = map (thing . mName . fst) pmDeps + do let currentModNames = map (thing . mName . fst) parsed depStatuses <- traverse scanFromImportSource - [ src - | (_,srcs) <- pmDeps - , src <- srcs - , importedModule src `notElem` currentModNames + [ dep + | (_,deps) <- parsed + , dep <- deps + , importedModule dep `notElem` currentModNames ] if LoadedChanged `elem` depStatuses @@ -147,6 +158,7 @@ scan mbIsrc mpath = +-- | Load a module that we have not yet parsed. parseAndLoad :: ImportSource -> ModulePath -> @@ -162,10 +174,7 @@ parseAndLoad isrc mpath = -{- | Process stuff we parsed from a file. -The reason we have a list of modules here, rather than just one, -is that a single file may contain multiple modules, due to to desugaring -of various things in the module system. -} +-- | Load a bunch of parsed modules. load :: Maybe ImportSource -> ModulePath -> @@ -173,8 +182,8 @@ load :: Map FilePath Fingerprint -> [(ModuleG ModName PName, [ImportSource])] -> LoadM [FileInfo] -load mbIsrc mpath newModFp newIncFps pmDeps = - for pmDeps \(pm, deps) -> +load mbIsrc mpath newModFp newIncFps mods = + for mods \(pm, deps) -> do let isrc = fromMaybe (FromModule (thing (mName pm))) mbIsrc liftCallback (loading isrc) do traverse_ loadFromImportSource deps @@ -182,6 +191,8 @@ load mbIsrc mpath newModFp newIncFps pmDeps = doLoadModule True False isrc mpath newModFp newIncFps pm $ Set.fromList (map importedModule deps) + +-- | This does the actual loading of the module (unless it is already loaded). loadFromImportSource :: ImportSource -> LoadM () loadFromImportSource isrc = do mpath <- findModule' isrc @@ -206,8 +217,9 @@ loadFromImportSource isrc = Nothing -> unlessLoaded do (newModFp, newIncFps, fis) <- parseAndLoad isrc mpath - foreignFps <- doModule $ getForeignFps $ - Map.unionsWith (||) (map fiForeignDeps fis) + foreignFps <- + doModule $ getForeignFps $ + Map.unionsWith (||) (map fiForeignDeps fis) let newFp = FullFingerprint { moduleFingerprint = newModFp , includeFingerprints = newIncFps @@ -219,8 +231,9 @@ loadFromImportSource isrc = Just oldFp | oldFp == newFp -> LoadedNotChanged _ -> LoadedChanged --- | Fingerprints of foreign declarations -getForeignFps :: Map FilePath Bool -> M.ModuleM (Set Fingerprint) + +-- | Get the fingerprints for external libraries. +getForeignFps :: Map FilePath Bool -> ModuleM (Set Fingerprint) getForeignFps fsrcPaths = Set.fromList <$> for (Map.keys fsrcPaths) \fsrcPath -> diff --git a/src/Cryptol/Project/Monad.hs b/src/Cryptol/Project/Monad.hs index 23a3d17f6..a140532fa 100644 --- a/src/Cryptol/Project/Monad.hs +++ b/src/Cryptol/Project/Monad.hs @@ -102,7 +102,7 @@ insertScanned mpath fp status = (modify' \ls -> ls { scanned = Map.insert mpath (fp, status) (scanned ls) }) --- | Get a lab for the given module path. +-- | Get a label for the given module path. -- Typically used for output. getModulePathLabel :: ModulePath -> LoadM String getModulePathLabel mpath = From 40305d0cb5f28e221d766a267d3669460fc8db2d Mon Sep 17 00:00:00 2001 From: Iavor Diatchki Date: Tue, 13 Feb 2024 14:59:33 -0800 Subject: [PATCH 16/35] Read cache file strictly, otherwise we can't overwrite it. --- src/Cryptol/Project/Cache.hs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Cryptol/Project/Cache.hs b/src/Cryptol/Project/Cache.hs index d96ff60e6..8d8538562 100644 --- a/src/Cryptol/Project/Cache.hs +++ b/src/Cryptol/Project/Cache.hs @@ -2,6 +2,8 @@ module Cryptol.Project.Cache where import Data.Map.Strict (Map) import qualified Data.Map.Strict as Map +import qualified Data.Text as Text +import qualified Data.Text.IO as Text import Data.Set (Set) import Data.Maybe (fromMaybe) import System.Directory @@ -38,8 +40,8 @@ emptyLoadCache = LoadCache { cacheFingerprints = Map.empty } loadLoadCache :: IO LoadCache loadLoadCache = - do txt <- readFile loadCachePath - pure (fromMaybe emptyLoadCache (readMaybe txt)) + do txt <- Text.readFile loadCachePath + pure $! fromMaybe emptyLoadCache (readMaybe (Text.unpack txt)) `catchIOError` \_ -> pure emptyLoadCache saveLoadCache :: LoadCache -> IO () From 9431d4df794c177af230b6416215620c97d4999b Mon Sep 17 00:00:00 2001 From: Iavor Diatchki Date: Tue, 13 Feb 2024 14:59:57 -0800 Subject: [PATCH 17/35] Ignore `.` and `..` --- src/Cryptol/Project.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Cryptol/Project.hs b/src/Cryptol/Project.hs index 320792764..547c2cb30 100644 --- a/src/Cryptol/Project.hs +++ b/src/Cryptol/Project.hs @@ -78,7 +78,7 @@ scanPath path = do isDir <- doIO (doesDirectoryExist path) if isDir then - doIO (tryIOError (getDirectoryContents path)) >>= + doIO (tryIOError (listDirectory path)) >>= \case Left err -> doModule (otherIOError path err) Right entries -> for_ entries \entry -> scanPath (path FP. entry) From 73ddf4df1273b790cedbdb2c92c8eecff095088d Mon Sep 17 00:00:00 2001 From: Iavor Diatchki Date: Tue, 13 Feb 2024 15:00:13 -0800 Subject: [PATCH 18/35] Move printing to monad --- src/Cryptol/Project.hs | 9 +++++---- src/Cryptol/Project/Monad.hs | 7 +++++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/Cryptol/Project.hs b/src/Cryptol/Project.hs index 547c2cb30..da6cbb11a 100644 --- a/src/Cryptol/Project.hs +++ b/src/Cryptol/Project.hs @@ -1,6 +1,5 @@ {-# LANGUAGE BlockArguments #-} {-# LANGUAGE LambdaCase #-} - module Cryptol.Project ( Config(..) , loadConfig @@ -28,7 +27,6 @@ import Cryptol.ModuleSystem.Monad as M import Cryptol.Parser.AST import Cryptol.REPL.Command import Cryptol.REPL.Monad as REPL -import Cryptol.Utils.Logger import Cryptol.Utils.PP as PP import Cryptol.Project.Config import Cryptol.Project.Cache @@ -64,6 +62,9 @@ loadProject cfg = M.io (saveLoadCache cache) pure (snd <$> info) + +-------------------------------------------------------------------------------- + {- NOTE: In the functions below: * "scan" refers to processing a module, but not necesserily loading it, @@ -115,11 +116,11 @@ scan mbIsrc mpath = Nothing -> liftCallback (errorInFile mpath) do lab <- getModulePathLabel mpath + lPutStrLn ("Scanning " ++ lab) (fi, parsed, foreignFps) <- doModule - do withLogger logPutStrLn ("Scanning " ++ lab) - (fi, parsed) <- parseWithDeps mpath + do (fi, parsed) <- parseWithDeps mpath foreignFps <- getForeignFps (fiForeignDeps fi) pure (fi, parsed, foreignFps) diff --git a/src/Cryptol/Project/Monad.hs b/src/Cryptol/Project/Monad.hs index a140532fa..836d150c6 100644 --- a/src/Cryptol/Project/Monad.hs +++ b/src/Cryptol/Project/Monad.hs @@ -13,6 +13,7 @@ module Cryptol.Project.Monad , getCachedFingerprint , findModule' , getStatus + , lPutStrLn ) where import Data.Map.Strict (Map) @@ -26,6 +27,7 @@ import Cryptol.Utils.Ident import Cryptol.ModuleSystem.Base as M import Cryptol.ModuleSystem.Monad as M import Cryptol.ModuleSystem.Env +import Cryptol.Utils.Logger (logPutStrLn) import Cryptol.Project.Config import Cryptol.Project.Cache @@ -43,6 +45,7 @@ data ScanStatus | NotLoadedNotChanged -- ^ The module is not loaded and did not change + deriving Eq data LoadState = LoadState @@ -72,6 +75,10 @@ doModule m = LoadM (lift (lift m)) doIO :: IO a -> LoadM a doIO m = doModule (M.io m) +-- | Print a line +lPutStrLn :: String -> LoadM () +lPutStrLn msg = doModule (withLogger logPutStrLn msg) + -- | Lift a module level operation to the LoadM monad. liftCallback :: (forall a. ModuleM a -> ModuleM a) -> LoadM b -> LoadM b liftCallback f (LoadM m) = From 088fa6087f34e200abccba0d5fd4bb1a9ef40774 Mon Sep 17 00:00:00 2001 From: Iavor Diatchki Date: Tue, 13 Feb 2024 15:01:00 -0800 Subject: [PATCH 19/35] Add a function for catching errors. This can be useful to implement loading projects partially, when some of the files in them are broken. --- src/Cryptol/ModuleSystem/Monad.hs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Cryptol/ModuleSystem/Monad.hs b/src/Cryptol/ModuleSystem/Monad.hs index dc38bea67..bc934455d 100644 --- a/src/Cryptol/ModuleSystem/Monad.hs +++ b/src/Cryptol/ModuleSystem/Monad.hs @@ -274,6 +274,9 @@ errorInFile file (ModuleT m) = ModuleT (m `handle` h) ErrorInFile {} -> e _ -> ErrorInFile file e +tryModule :: ModuleM a -> ModuleM (Either ModuleError a) +tryModule (ModuleT m) = ModuleT (handle (Right <$> m) (pure . Left)) + -- Warnings -------------------------------------------------------------------- data ModuleWarning From 5093908fc07181ee6733abfe7a0bc0ced6bf05db Mon Sep 17 00:00:00 2001 From: Iavor Diatchki Date: Tue, 27 Feb 2024 14:37:34 -0800 Subject: [PATCH 20/35] Simplify things a bit. For the moment we separate loading files and just parsing to check for changes. --- cryptol.cabal | 2 +- src/Cryptol/ModuleSystem/Base.hs | 11 +- src/Cryptol/ModuleSystem/Monad.hs | 25 +-- src/Cryptol/Project.hs | 261 ++++++++++++------------------ src/Cryptol/Project/Config.hs | 55 ++++--- src/Cryptol/Project/Monad.hs | 143 +++++++++++----- 6 files changed, 257 insertions(+), 240 deletions(-) diff --git a/cryptol.cabal b/cryptol.cabal index 57999af1a..b5017e089 100644 --- a/cryptol.cabal +++ b/cryptol.cabal @@ -64,7 +64,6 @@ library ghc-prim, GraphSCC >= 1.0.4, heredoc >= 0.2, - HsYAML, language-c99, language-c99-simple, libBF >= 0.6 && < 0.7, @@ -82,6 +81,7 @@ library strict, text >= 1.1, tf-random >= 0.5, + toml-parser >= 2.0 && <2.1, transformers-base >= 0.4, vector, mtl >= 2.2.1, diff --git a/src/Cryptol/ModuleSystem/Base.hs b/src/Cryptol/ModuleSystem/Base.hs index a0df5096b..891aaa48f 100644 --- a/src/Cryptol/ModuleSystem/Base.hs +++ b/src/Cryptol/ModuleSystem/Base.hs @@ -181,9 +181,11 @@ parseModule path = do , "Label: " ++ show p , "Exception: " ++ show exn ] + let fp = fingerprint bytes txt <- case decodeUtf8' bytes of - Right txt -> return $! (T.replace "\r\n" "\n" txt) - Left e -> badUtf8 path e + Right txt -> return txt + Left e -> badUtf8 path fp e + let cfg = P.defaultConfig { P.cfgSource = case path of @@ -194,8 +196,7 @@ parseModule path = do case P.parseModule cfg txt of Right pms -> - do let fp = fingerprint bytes - (pm1,deps) <- + do (pm1,deps) <- case path of InFile p -> do r <- getByteReader @@ -222,7 +223,7 @@ parseModule path = do --} fp `seq` return (fp, deps, pm1) - Left err -> moduleParseError path err + Left err -> moduleParseError path fp err -- Top Level Modules and Signatures -------------------------------------------- diff --git a/src/Cryptol/ModuleSystem/Monad.hs b/src/Cryptol/ModuleSystem/Monad.hs index bc934455d..dcd34dfee 100644 --- a/src/Cryptol/ModuleSystem/Monad.hs +++ b/src/Cryptol/ModuleSystem/Monad.hs @@ -26,6 +26,7 @@ import Cryptol.ModuleSystem.Interface import Cryptol.ModuleSystem.Name (FreshM(..),Supply) import Cryptol.ModuleSystem.Renamer (RenamerError(),RenamerWarning()) import Cryptol.ModuleSystem.NamingEnv(NamingEnv) +import Cryptol.ModuleSystem.Fingerprint(Fingerprint) import qualified Cryptol.Parser as Parser import qualified Cryptol.Parser.AST as P import Cryptol.Utils.Panic (panic) @@ -94,11 +95,11 @@ data ModuleError -- ^ Unable to find the module given, tried looking in these paths | CantFindFile FilePath -- ^ Unable to open a file - | BadUtf8 ModulePath UnicodeException + | BadUtf8 ModulePath Fingerprint UnicodeException -- ^ Bad UTF-8 encoding in while decoding this file | OtherIOError FilePath IOException -- ^ Some other IO error occurred while reading this file - | ModuleParseError ModulePath Parser.ParseError + | ModuleParseError ModulePath Fingerprint Parser.ParseError -- ^ Generated this parse error when parsing the file for module m | RecursiveModules [ImportSource] -- ^ Recursive module group discovered @@ -124,7 +125,7 @@ data ModuleError | ErrorInFile ModulePath ModuleError -- ^ This is just a tag on the error, indicating the file containing it. -- It is convenient when we had to look for the module, and we'd like - -- to communicate the location of pthe problematic module to the handler. + -- to communicate the location of the problematic module to the handler. deriving (Show) @@ -132,9 +133,9 @@ instance NFData ModuleError where rnf e = case e of ModuleNotFound src path -> src `deepseq` path `deepseq` () CantFindFile path -> path `deepseq` () - BadUtf8 path ue -> rnf (path, ue) + BadUtf8 path fp ue -> rnf (path, fp, ue) OtherIOError path exn -> path `deepseq` exn `seq` () - ModuleParseError source err -> source `deepseq` err `deepseq` () + ModuleParseError source fp err -> rnf (source, fp, err) RecursiveModules mods -> mods `deepseq` () RenamerErrors src errs -> src `deepseq` errs `deepseq` () NoPatErrors src errs -> src `deepseq` errs `deepseq` () @@ -165,7 +166,7 @@ instance PP ModuleError where text "[error]" <+> text "can't find file:" <+> text path - BadUtf8 path _ue -> + BadUtf8 path _fp _ue -> text "[error]" <+> text "bad utf-8 encoding:" <+> pp path @@ -174,7 +175,7 @@ instance PP ModuleError where text "IO error while loading file:" <+> text path <.> colon) 4 (text (show exn)) - ModuleParseError _source err -> Parser.ppError err + ModuleParseError _source _fp err -> Parser.ppError err RecursiveModules mods -> hang (text "[error] module imports form a cycle:") @@ -217,15 +218,15 @@ moduleNotFound name paths = ModuleT (raise (ModuleNotFound name paths)) cantFindFile :: FilePath -> ModuleM a cantFindFile path = ModuleT (raise (CantFindFile path)) -badUtf8 :: ModulePath -> UnicodeException -> ModuleM a -badUtf8 path ue = ModuleT (raise (BadUtf8 path ue)) +badUtf8 :: ModulePath -> Fingerprint -> UnicodeException -> ModuleM a +badUtf8 path fp ue = ModuleT (raise (BadUtf8 path fp ue)) otherIOError :: FilePath -> IOException -> ModuleM a otherIOError path exn = ModuleT (raise (OtherIOError path exn)) -moduleParseError :: ModulePath -> Parser.ParseError -> ModuleM a -moduleParseError path err = - ModuleT (raise (ModuleParseError path err)) +moduleParseError :: ModulePath -> Fingerprint -> Parser.ParseError -> ModuleM a +moduleParseError path fp err = + ModuleT (raise (ModuleParseError path fp err)) recursiveModules :: [ImportSource] -> ModuleM a recursiveModules loaded = ModuleT (raise (RecursiveModules loaded)) diff --git a/src/Cryptol/Project.hs b/src/Cryptol/Project.hs index da6cbb11a..3d19820ef 100644 --- a/src/Cryptol/Project.hs +++ b/src/Cryptol/Project.hs @@ -8,23 +8,20 @@ module Cryptol.Project , loadProjectREPL ) where -import Control.Monad (void,unless) +import Control.Monad (void) import Data.Foldable import Data.Map.Strict (Map) import qualified Data.Map.Strict as Map -import Data.Maybe import Data.Set (Set) import qualified Data.Set as Set import Data.Traversable import System.Directory import System.FilePath as FP -import System.IO.Error import Cryptol.ModuleSystem.Base as M import Cryptol.ModuleSystem.Env import Cryptol.ModuleSystem.Fingerprint import Cryptol.ModuleSystem.Monad as M -import Cryptol.Parser.AST import Cryptol.REPL.Command import Cryptol.REPL.Monad as REPL import Cryptol.Utils.PP as PP @@ -48,190 +45,115 @@ loadProjectREPL cfg = rPrint (pp (ModuleSystemError names err)) pure emptyCommandResult { crSuccess = False } - Right _ -> - do rPutStrLn "all loaded!" - pure emptyCommandResult - + Right (mp,_) -> do + -- rPutStrLn "all loaded!" + rPutStrLn $ unlines + [ ppScanStatus v ++ " " ++ show (pp k) + | (k,v) <- Map.toList mp + ] + pure emptyCommandResult -- | Load a project. -- Returns information about the modules that are part of the project. loadProject :: Config -> M.ModuleM (Map ModulePath ScanStatus) loadProject cfg = - do info <- runLoadM cfg (for_ (modules cfg) scanPath) - let cache = LoadCache { cacheFingerprints = fst <$> info } + do (fps, status) <- runLoadM cfg (for_ (modules cfg) scanPath) + let cache = LoadCache { cacheFingerprints = fps } M.io (saveLoadCache cache) - pure (snd <$> info) + pure status -------------------------------------------------------------------------------- -{- NOTE: -In the functions below: - * "scan" refers to processing a module, but not necesserily loading it, - * "load" means that we are actually loading the module. --} - - - -- | Process all .cry files in the given path. -scanPath :: FilePath -> LoadM () +scanPath :: FilePath -> LoadM any () scanPath path = - do isDir <- doIO (doesDirectoryExist path) - if isDir - then - doIO (tryIOError (listDirectory path)) >>= - \case - Left err -> doModule (otherIOError path err) - Right entries -> for_ entries \entry -> scanPath (path FP. entry) - else - -- XXX: This should probably handle other extenions - -- (literate Cryptol) - case takeExtension path of - ".cry" -> scanFromPath path - _ -> pure () + tryLoadM (doIO (doesDirectoryExist path)) >>= + \case + Left {} -> pure () + + Right True -> + tryLoadM (doIO (listDirectory path)) >>= + \case + Left {} -> pure () + Right entries -> + for_ entries \entry -> scanPath (path FP. entry) + + Right False -> + -- XXX: This should probably handle other extenions + -- (literate Cryptol) + case takeExtension path of + ".cry" -> void (tryLoadM (scanFromPath path)) + -- XXX: failure: file disappeared. + _ -> pure () -- | Process a particular file path. -scanFromPath :: FilePath -> LoadM () +-- Fails if we can't find the module at this path. +scanFromPath :: FilePath -> LoadM Err ScanStatus scanFromPath fpath = liftCallback (withPrependedSearchPath [takeDirectory fpath]) do foundFPath <- doModule (M.findFile fpath) mpath <- doIO (InFile <$> canonicalizePath foundFPath) - void (scan Nothing mpath) - - --- | Process a particular import source. -scanFromImportSource :: ImportSource -> LoadM ScanStatus -scanFromImportSource isrc = - do mpath <- findModule' isrc - scan (Just isrc) mpath + scan mpath -- | Process the given module, and return information about what happened. -scan :: Maybe ImportSource -> ModulePath -> LoadM ScanStatus -scan mbIsrc mpath = +-- Also, saves the status of the module path. +scan :: ModulePath -> LoadM any ScanStatus +scan mpath = + + tryIt $ do mbStat <- getStatus mpath case mbStat of - Just (_, status) -> pure status + Just status -> pure status + Nothing -> - liftCallback (errorInFile mpath) - do lab <- getModulePathLabel mpath - lPutStrLn ("Scanning " ++ lab) - - (fi, parsed, foreignFps) <- - doModule - do (fi, parsed) <- parseWithDeps mpath - foreignFps <- getForeignFps (fiForeignDeps fi) - pure (fi, parsed, foreignFps) - - let newFp = - FullFingerprint + do (newFp,parsed) <- doParse mpath + mbOldFP <- getCachedFingerprint mpath + let needLoad = mbOldFP /= Just newFp + let deps = [ dep + | (_,ds) <- parsed + , dep@(_,otherPath) <- ds + , mpath /= otherPath + ] + mb <- checkDeps False deps + case mb of + Left (a,b) -> addScanned mpath (Invalid (InvalidDep a b)) + Right depChanges -> + do let ch = if needLoad || depChanges + then Changed else Unchanged + addScanned mpath (Scanned ch newFp parsed) + where + tryIt m = + do mb <- tryLoadM m + case mb of + Left err -> addScanned mpath (Invalid (InvalidModule err)) + Right a -> pure a + + +-- | Parse a module. +doParse :: ModulePath -> LoadM Err (FullFingerprint, Parsed) +doParse mpath = + do lab <- getModulePathLabel mpath + lPutStrLn ("Scanning " ++ lab) + + (parsed, newFp) <- + doModule + do (fi, parsed) <- parseWithDeps mpath + foreignFps <- getForeignFps (fiForeignDeps fi) + pure ( parsed + , FullFingerprint { moduleFingerprint = fiFingerprint fi , includeFingerprints = fiIncludeDeps fi , foreignFingerprints = foreignFps } - - loadChanged = - LoadedChanged <$ - load mbIsrc mpath - (fiFingerprint fi) (fiIncludeDeps fi) parsed - - mbOldFP <- getCachedFingerprint mpath - status <- - case mbOldFP of - Just oldFp | oldFp == newFp -> - do let currentModNames = map (thing . mName . fst) parsed - depStatuses <- - traverse scanFromImportSource - [ dep - | (_,deps) <- parsed - , dep <- deps - , importedModule dep `notElem` currentModNames - ] - - if LoadedChanged `elem` depStatuses - then loadChanged - else pure NotLoadedNotChanged - _ -> loadChanged - - insertScanned mpath newFp status - pure status - - - --- | Load a module that we have not yet parsed. -parseAndLoad :: - ImportSource -> - ModulePath -> - LoadM (Fingerprint, Map FilePath Fingerprint, [FileInfo]) -parseAndLoad isrc mpath = - do (newModFp, newIncFps, pms) <- doModule (parseModule mpath) - fis <- load (Just isrc) mpath newModFp newIncFps - [ (pm', findDeps pm') - | pm <- pms - , let pm' = addPrelude pm - ] - pure (newModFp, newIncFps, fis) - - - --- | Load a bunch of parsed modules. -load :: - Maybe ImportSource -> - ModulePath -> - Fingerprint -> - Map FilePath Fingerprint -> - [(ModuleG ModName PName, [ImportSource])] -> - LoadM [FileInfo] -load mbIsrc mpath newModFp newIncFps mods = - for mods \(pm, deps) -> - do let isrc = fromMaybe (FromModule (thing (mName pm))) mbIsrc - liftCallback (loading isrc) - do traverse_ loadFromImportSource deps - doModule $ fmap snd $ - doLoadModule True False isrc mpath newModFp newIncFps pm $ - Set.fromList (map importedModule deps) - - --- | This does the actual loading of the module (unless it is already loaded). -loadFromImportSource :: ImportSource -> LoadM () -loadFromImportSource isrc = - do mpath <- findModule' isrc - let unlessLoaded k = - do loaded <- doModule (M.isLoadedStrict (importedModule isrc) mpath) - unless loaded k - - liftCallback (errorInFile mpath) - do mbScanned <- getStatus mpath - case mbScanned of - Just (fp, status) -> - case status of - LoadedChanged -> pure () - LoadedNotChanged -> pure () - NotLoadedNotChanged -> - unlessLoaded - do _ <- parseAndLoad isrc mpath - insertScanned mpath fp LoadedNotChanged - - -- The file has not been fully loaded yet, but the individual - -- module within the file might - Nothing -> - unlessLoaded - do (newModFp, newIncFps, fis) <- parseAndLoad isrc mpath - foreignFps <- - doModule $ getForeignFps $ - Map.unionsWith (||) (map fiForeignDeps fis) - let newFp = FullFingerprint - { moduleFingerprint = newModFp - , includeFingerprints = newIncFps - , foreignFingerprints = foreignFps - } - mbOldFP <- getCachedFingerprint mpath - insertScanned mpath newFp - case mbOldFP of - Just oldFp | oldFp == newFp -> LoadedNotChanged - _ -> LoadedChanged - + ) + addFingerprint mpath newFp + ps <- forM parsed \(m,ds) -> + do paths <- mapM findModule' ds + pure (m, zip ds paths) + pure (newFp, ps) -- | Get the fingerprints for external libraries. getForeignFps :: Map FilePath Bool -> ModuleM (Set Fingerprint) @@ -243,5 +165,24 @@ getForeignFps fsrcPaths = Left ioe -> otherIOError fsrcPath ioe Right fp -> pure fp - +-- | Scan the dependencies of a module. +checkDeps :: + Bool {- ^ Should we load the dependencies -} -> + [(ImportSource,ModulePath)] {- ^ The dependencies -} -> + LoadM err (Either (ImportSource,ModulePath) Bool) + -- ^ Returns `Left bad_dep` if one of the dependencies fails to load. + -- Returns `Right changes` if all dependencies were validated correctly. + -- The boolean flag `changes` indicates if any of the dependencies contain + -- changes and so we should also load the main module. +checkDeps shouldLoad ds = + case ds of + [] -> pure (Right shouldLoad) + (imp, mpath) : more -> + do status <- scan mpath + case status of + Invalid {} -> pure (Left (imp,mpath)) + Scanned ch _ _ -> + case ch of + Changed -> checkDeps True more + Unchanged -> checkDeps shouldLoad more diff --git a/src/Cryptol/Project/Config.hs b/src/Cryptol/Project/Config.hs index 7374ea965..697b3cbee 100644 --- a/src/Cryptol/Project/Config.hs +++ b/src/Cryptol/Project/Config.hs @@ -1,12 +1,11 @@ {-# LANGUAGE BlockArguments #-} -{-# LANGUAGE NamedFieldPuns #-} {-# LANGUAGE OverloadedStrings #-} module Cryptol.Project.Config where -import qualified Data.Text as Text -import Data.YAML -import qualified Data.ByteString as BS.Strict -import qualified Data.ByteString.Lazy as BS.Lazy +import Data.Maybe (fromMaybe) +import qualified Data.Text.IO as Text +import Toml +import Toml.Schema import Data.Bifunctor (first) import System.Directory import System.FilePath as FP @@ -19,23 +18,29 @@ data Config = Config , modules :: [FilePath] } -instance FromYAML Config where - parseYAML = withMap "Config" \m -> - do root <- Text.unpack <$> m .:? "root" .!= "." - modules <- map Text.unpack <$> m .:? "modules" .!= ["."] - pure Config { root, modules } +instance FromValue Config where + fromValue = + parseTableFromValue + do mbRoot <- optKey "root" + mbModules <- optKey "modules" + pure Config + { root = fromMaybe "." mbRoot + , modules = fromMaybe ["."] mbModules + } data ConfigLoadError = ConfigLoadError FilePath ConfigLoadErrorInfo data ConfigLoadErrorInfo - = ConfigParseError BS.Lazy.ByteString (Pos, String) + = ConfigParseError [String] | SetRootFailed IOError instance PP ConfigLoadError where ppPrec _ (ConfigLoadError path info) = case info of - ConfigParseError file (pos, err) -> text $ + ConfigParseError errs -> text $ unlines errs +{- show topMsg ++ prettyPosWithSource pos file "\nParse error:" ++ err +-} SetRootFailed ioe -> hang topMsg 4 (hang "Failed to set project root:" @@ -45,18 +50,18 @@ instance PP ConfigLoadError where -- | Parse project configuration. loadConfig :: FilePath -> IO (Either ConfigLoadError Config) -loadConfig path = do - isDir <- doesDirectoryExist path - let filePath = if isDir then path FP. "cryproject.yaml" else path - -- Use strict IO since we are writing to the same file later - file <- BS.Lazy.fromStrict <$> BS.Strict.readFile filePath - first (ConfigLoadError filePath) <$> - case decode1 file of - Left (pos, err) -> pure (Left (ConfigParseError file (pos, err))) - Right config -> - first SetRootFailed <$> - tryIOError - do setCurrentDirectory (takeDirectory filePath FP. root config) - pure config +loadConfig path = + do isDir <- doesDirectoryExist path + let filePath = if isDir then path FP. "cryproject.toml" else path + -- Use strict IO since we are writing to the same file later + file <- Text.readFile filePath + first (ConfigLoadError filePath) <$> + case decode file of + Failure errs -> pure (Left (ConfigParseError errs)) + Success _warns config -> + first SetRootFailed <$> + tryIOError + do setCurrentDirectory (takeDirectory filePath FP. root config) + pure config diff --git a/src/Cryptol/Project/Monad.hs b/src/Cryptol/Project/Monad.hs index 836d150c6..e92998bbb 100644 --- a/src/Cryptol/Project/Monad.hs +++ b/src/Cryptol/Project/Monad.hs @@ -1,18 +1,24 @@ {-# LANGUAGE BlockArguments #-} {-# LANGUAGE RankNTypes #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} +{-# LANGUAGE OverloadedStrings #-} module Cryptol.Project.Monad - ( LoadM - , ScanStatus(..) + ( LoadM, Err, NoErr + , ScanStatus(..), ChangeStatus(..), InvalidStatus(..), Parsed + , ppScanStatus , runLoadM , doModule + , doModuleNonFail , doIO + , tryLoadM , liftCallback - , insertScanned + , addFingerprint + , addScanned , getModulePathLabel , getCachedFingerprint , findModule' , getStatus + , getFingerprint , lPutStrLn ) where @@ -20,10 +26,12 @@ import Data.Map.Strict (Map) import qualified Data.Map.Strict as Map import Control.Monad.Reader import Control.Monad.State +import Control.Monad.Except import System.Directory import System.FilePath (makeRelative) import Cryptol.Utils.Ident +import Cryptol.Parser.AST (Module,PName) import Cryptol.ModuleSystem.Base as M import Cryptol.ModuleSystem.Monad as M import Cryptol.ModuleSystem.Env @@ -32,30 +40,60 @@ import Cryptol.Utils.Logger (logPutStrLn) import Cryptol.Project.Config import Cryptol.Project.Cache -newtype LoadM a = LoadM (ReaderT LoadConfig (StateT LoadState ModuleM) a) +newtype LoadM err a = + LoadM (ReaderT LoadConfig (ExceptT ModuleError (StateT LoadState ModuleM)) a) deriving (Functor,Applicative,Monad) -data ScanStatus - = LoadedChanged - -- ^ The module is loaded and has changed +-- | Computations may raise an error +data Err - | LoadedNotChanged - -- ^ The module is loaded but did not change - -- This may happen because it is a dependency of something the did change +-- | Computations may not raise errors +data NoErr - | NotLoadedNotChanged - -- ^ The module is not loaded and did not change +type Parsed = [ (Module PName, [(ImportSource, ModulePath)]) ] + +data ScanStatus = + Scanned ChangeStatus FullFingerprint Parsed + | Invalid InvalidStatus + +data ChangeStatus = + Changed -- ^ The module, or one of its dependencies changed. + | Unchanged -- ^ The module did not change. + +data InvalidStatus = + InvalidModule ModuleError + -- ^ Error in one of the modules in this file + + | InvalidDep ImportSource ModulePath + -- ^ Error in one of our dependencies + + + +ppScanStatus :: ScanStatus -> String +ppScanStatus status = + case status of + Scanned ch _ _ -> + case ch of + Unchanged -> "[Unchanged]" + Changed -> "[Changed ]" + Invalid reason -> + case reason of + InvalidModule {} -> "[Invalid ]" + InvalidDep {} -> "[InvalidD ]" - deriving Eq data LoadState = LoadState { findModuleCache :: Map (ModName, [FilePath]) ModulePath -- ^ Map (module name, search path) -> module path - , scanned :: Map ModulePath (FullFingerprint, ScanStatus) - -- ^ Information about the proccessed modules. + , fingerprints :: Map ModulePath FullFingerprint + -- ^ Hashes of known things. + + , scanned :: Map ModulePath ScanStatus + -- ^ Information about the proccessed top-level modules. } + -- | Information about the current project. data LoadConfig = LoadConfig { canonRoot :: FilePath @@ -63,55 +101,80 @@ data LoadConfig = LoadConfig , loadCache :: LoadCache -- ^ The state of the cache before we started loading the project. - } -- | Do an operation in the module monad. -doModule :: M.ModuleM a -> LoadM a -doModule m = LoadM (lift (lift m)) +doModuleNonFail :: M.ModuleM a -> LoadM any a +doModuleNonFail m = + do mb <- LoadM (lift (lift (lift (M.tryModule m)))) + case mb of + Left err -> LoadM (throwError err) + Right a -> pure a + +-- | Do an operation in the module monad. +doModule :: M.ModuleM a -> LoadM Err a +doModule = doModuleNonFail -- | Do an operation in the IO monad -doIO :: IO a -> LoadM a +doIO :: IO a -> LoadM Err a doIO m = doModule (M.io m) +tryLoadM :: LoadM Err a -> LoadM any (Either M.ModuleError a) +tryLoadM (LoadM m) = LoadM (tryError m) + -- | Print a line -lPutStrLn :: String -> LoadM () -lPutStrLn msg = doModule (withLogger logPutStrLn msg) +lPutStrLn :: String -> LoadM any () +lPutStrLn msg = doModuleNonFail (withLogger logPutStrLn msg) -- | Lift a module level operation to the LoadM monad. -liftCallback :: (forall a. ModuleM a -> ModuleM a) -> LoadM b -> LoadM b +liftCallback :: (forall a. ModuleM a -> ModuleM a) -> LoadM any b -> LoadM Err b liftCallback f (LoadM m) = do r <- LoadM ask s <- LoadM get - (a,s1) <- doModule (f (runStateT (runReaderT m r) s)) + (mb,s1) <- doModule (f (runStateT (runExceptT (runReaderT m r)) s)) LoadM (put s1) - pure a + case mb of + Left err -> LoadM (throwError err) + Right a -> pure a -- | Run a LoadM computation using the given configuration. runLoadM :: - Config -> LoadM () -> M.ModuleM (Map ModulePath (FullFingerprint, ScanStatus)) + Config -> + LoadM NoErr () -> + M.ModuleM (Map ModulePath FullFingerprint, Map ModulePath ScanStatus) runLoadM cfg (LoadM m) = do loadCfg <- M.io do path <- canonicalizePath (root cfg) cache <- loadLoadCache - pure LoadConfig { canonRoot = path, loadCache = cache } - let loadState = LoadState { findModuleCache = Map.empty - , scanned = Map.empty + pure LoadConfig { canonRoot = path + , loadCache = cache + } + let loadState = LoadState { findModuleCache = mempty + , fingerprints = mempty + , scanned = mempty } - scanned <$> execStateT (runReaderT m loadCfg) loadState + s <- execStateT (runExceptT (runReaderT m loadCfg)) loadState + pure (fingerprints s, scanned s) --- | Add information about the status of a module path. -insertScanned :: ModulePath -> FullFingerprint -> ScanStatus -> LoadM () -insertScanned mpath fp status = +addFingerprint :: ModulePath -> FullFingerprint -> LoadM any () +addFingerprint mpath fp = LoadM - (modify' \ls -> ls { scanned = Map.insert mpath (fp, status) (scanned ls) }) + (modify' \ls -> ls { fingerprints = Map.insert mpath fp (fingerprints ls) }) + + +-- | Add information about the status of a module path. +addScanned :: ModulePath -> ScanStatus -> LoadM any ScanStatus +addScanned mpath status = + do LoadM + (modify' \ls -> ls { scanned = Map.insert mpath status (scanned ls) }) + pure status -- | Get a label for the given module path. -- Typically used for output. -getModulePathLabel :: ModulePath -> LoadM String +getModulePathLabel :: ModulePath -> LoadM any String getModulePathLabel mpath = case mpath of InFile p -> LoadM (asks ((`makeRelative` p) . canonRoot)) @@ -119,13 +182,13 @@ getModulePathLabel mpath = -- | Get the fingerprint for the given module path. -getCachedFingerprint :: ModulePath -> LoadM (Maybe FullFingerprint) +getCachedFingerprint :: ModulePath -> LoadM any (Maybe FullFingerprint) getCachedFingerprint mpath = LoadM (asks (Map.lookup mpath . cacheFingerprints . loadCache)) -- | Module path for the given import -findModule' :: ImportSource -> LoadM ModulePath +findModule' :: ImportSource -> LoadM Err ModulePath findModule' isrc = do ls <- LoadM get let mname = modNameToNormalModName (importedModule isrc) @@ -142,5 +205,11 @@ findModule' isrc = pure mpath -- | Check if the given file has beein processed. -getStatus :: ModulePath -> LoadM (Maybe (FullFingerprint, ScanStatus)) +getStatus :: ModulePath -> LoadM any (Maybe ScanStatus) getStatus mpath = LoadM (gets (Map.lookup mpath . scanned)) + +-- | Get the fingerpint for the ginve path, if any. +getFingerprint :: ModulePath -> LoadM any (Maybe FullFingerprint) +getFingerprint mpath = LoadM (gets (Map.lookup mpath . fingerprints)) + + From 55a76f903f1f2a064d67fa783dbd5d7b94e29b4d Mon Sep 17 00:00:00 2001 From: Eric Mertens Date: Fri, 22 Nov 2024 15:26:22 -0800 Subject: [PATCH 21/35] Project load with docstrings checkpoint --- cryptol-repl-internal/REPL/Haskeline.hs | 2 +- cryptol/Main.hs | 2 +- src/Cryptol/ModuleSystem/Base.hs | 2 +- src/Cryptol/ModuleSystem/Fingerprint.hs | 34 +++++-- src/Cryptol/Project.hs | 86 +++++++++------- src/Cryptol/Project/Cache.hs | 87 +++++++++++++--- src/Cryptol/Project/Monad.hs | 28 ++---- src/Cryptol/REPL/Command.hs | 126 ++++++++++++++++-------- 8 files changed, 248 insertions(+), 119 deletions(-) diff --git a/cryptol-repl-internal/REPL/Haskeline.hs b/cryptol-repl-internal/REPL/Haskeline.hs index 134a17a13..8500eb9c6 100644 --- a/cryptol-repl-internal/REPL/Haskeline.hs +++ b/cryptol-repl-internal/REPL/Haskeline.hs @@ -152,7 +152,7 @@ repl cryrc projectConfig replMode callStacks stopOnError begin = if crSuccess status then do begin case projectConfig of - Just config -> Project.loadProjectREPL config + Just config -> loadProjectREPL config Nothing -> crySession replMode stopOnError else return status diff --git a/cryptol/Main.hs b/cryptol/Main.hs index 9f4e8d867..bd5de9928 100644 --- a/cryptol/Main.hs +++ b/cryptol/Main.hs @@ -86,7 +86,7 @@ options = , Option "p" ["project"] (ReqArg setProject "CRYPROJECT") ("Load and verify a Cryptol project using the provided project " - ++ "configuration file or directory containing 'cryproject.yaml'") + ++ "configuration file or directory containing 'cryproject.toml'") , Option "e" ["stop-on-error"] (NoArg setStopOnError) "stop script execution as soon as an error occurs." diff --git a/src/Cryptol/ModuleSystem/Base.hs b/src/Cryptol/ModuleSystem/Base.hs index 891aaa48f..e89939158 100644 --- a/src/Cryptol/ModuleSystem/Base.hs +++ b/src/Cryptol/ModuleSystem/Base.hs @@ -177,7 +177,7 @@ parseModule path = do | IOE.isDoesNotExistError exn -> cantFindFile p | otherwise -> otherIOError p exn InMem p _ -> panic "parseModule" - [ "IOError for in-memory contetns???" + [ "IOError for in-memory contents???" , "Label: " ++ show p , "Exception: " ++ show exn ] diff --git a/src/Cryptol/ModuleSystem/Fingerprint.hs b/src/Cryptol/ModuleSystem/Fingerprint.hs index 2fa9dfac2..1f17e212e 100644 --- a/src/Cryptol/ModuleSystem/Fingerprint.hs +++ b/src/Cryptol/ModuleSystem/Fingerprint.hs @@ -13,13 +13,15 @@ module Cryptol.ModuleSystem.Fingerprint , fingerprintHexString ) where -import Control.Monad ((<$!>)) import Control.DeepSeq (NFData (rnf)) -import Crypto.Hash.SHA1 (hash) -import Data.ByteString (ByteString) import Control.Exception (try) +import Control.Monad ((<$!>)) +import Crypto.Hash.SHA256 (hash) +import Data.ByteString (ByteString) +import Data.Char (intToDigit, digitToInt, isHexDigit) import qualified Data.ByteString as B -import qualified Data.Vector as Vector +import qualified Toml +import qualified Toml.Schema as Toml newtype Fingerprint = Fingerprint ByteString deriving (Eq, Ord, Show, Read) @@ -41,9 +43,25 @@ fingerprintFile path = fingerprintHexString :: Fingerprint -> String fingerprintHexString (Fingerprint bs) = B.foldr hex "" bs where - digits = Vector.fromList "0123456789ABCDEF" - digit x = digits Vector.! fromIntegral x - hex b cs = let (x,y) = divMod b 16 - in digit x : digit y : cs + hex b cs = let (x,y) = divMod (fromIntegral b) 16 + in intToDigit x : intToDigit y : cs + +fingerprintFromHexString :: String -> Maybe Fingerprint +fingerprintFromHexString str = Fingerprint . B.pack <$> go str + where + go [] = Just [] + go (x:y:z) + | isHexDigit x + , isHexDigit y + = (fromIntegral (digitToInt x * 16 + digitToInt y):) <$> go z + go _ = Nothing +instance Toml.ToValue Fingerprint where + toValue = Toml.toValue . fingerprintHexString +instance Toml.FromValue Fingerprint where + fromValue x = + do str <- Toml.fromValue x + case fingerprintFromHexString str of + Nothing -> Toml.failAt (Toml.valueAnn x) "malformed fingerprint hex-string" + Just fp -> pure fp diff --git a/src/Cryptol/Project.hs b/src/Cryptol/Project.hs index 3d19820ef..880d4d7cb 100644 --- a/src/Cryptol/Project.hs +++ b/src/Cryptol/Project.hs @@ -4,8 +4,11 @@ module Cryptol.Project ( Config(..) , loadConfig , ScanStatus(..) + , ChangeStatus(..) + , InvalidStatus(..) + , Parsed , loadProject - , loadProjectREPL + , depMap ) where import Control.Monad (void) @@ -22,45 +25,43 @@ import Cryptol.ModuleSystem.Base as M import Cryptol.ModuleSystem.Env import Cryptol.ModuleSystem.Fingerprint import Cryptol.ModuleSystem.Monad as M -import Cryptol.REPL.Command -import Cryptol.REPL.Monad as REPL -import Cryptol.Utils.PP as PP import Cryptol.Project.Config import Cryptol.Project.Cache import Cryptol.Project.Monad - - --- | Load a project. --- Note that this does not update the Cryptol environment, it only updates --- the project cache. --- XXX: Probably should move this in REPL -loadProjectREPL :: Config -> REPL CommandResult -loadProjectREPL cfg = - do minp <- getModuleInput - (res, warnings) <- REPL.io $ runModuleM minp $ loadProject cfg - printModuleWarnings warnings - case res of - Left err -> - do names <- mctxNameDisp <$> REPL.getFocusedEnv - rPrint (pp (ModuleSystemError names err)) - pure emptyCommandResult { crSuccess = False } - - Right (mp,_) -> do - -- rPutStrLn "all loaded!" - rPutStrLn $ unlines - [ ppScanStatus v ++ " " ++ show (pp k) - | (k,v) <- Map.toList mp - ] - pure emptyCommandResult +import qualified Cryptol.Parser.AST as P +import Cryptol.Parser.Position (Located(..)) -- | Load a project. -- Returns information about the modules that are part of the project. -loadProject :: Config -> M.ModuleM (Map ModulePath ScanStatus) +loadProject :: Config -> M.ModuleM (Map CacheModulePath FullFingerprint, Map ModulePath ScanStatus) loadProject cfg = - do (fps, status) <- runLoadM cfg (for_ (modules cfg) scanPath) + do (fps, statuses) <- runLoadM cfg (for_ (modules cfg) scanPath) let cache = LoadCache { cacheFingerprints = fps } + let deps = depMap [p | Scanned _ _ ps <- Map.elems statuses, p <- ps] + + let needLoad = [thing (P.mName m) | Scanned Changed _ ps <- Map.elems statuses, (m, _) <- ps] + + let order = loadOrder deps needLoad + + let modDetails = Map.fromList [(thing (P.mName m), (m, mp, fp)) | (mp, Scanned _ fp ps) <- Map.assocs statuses, (m, _) <- ps] + + let fingerprints = Map.fromList [(path, moduleFingerprint ffp) | (CacheInFile path, ffp) <- Map.assocs fps] + + for_ order \name -> + let (m, path, fp) = modDetails Map.! name in + -- XXX: catch modules that don't load? + doLoadModule + True {- eval -} + False {- quiet -} + (FromModule name) + path + (moduleFingerprint fp) + fingerprints + m + (deps Map.! name) + M.io (saveLoadCache cache) - pure status + pure (fps, statuses) -------------------------------------------------------------------------------- @@ -147,6 +148,7 @@ doParse mpath = { moduleFingerprint = fiFingerprint fi , includeFingerprints = fiIncludeDeps fi , foreignFingerprints = foreignFps + , moduleDoctestResult = Nothing } ) addFingerprint mpath newFp @@ -159,11 +161,12 @@ doParse mpath = getForeignFps :: Map FilePath Bool -> ModuleM (Set Fingerprint) getForeignFps fsrcPaths = Set.fromList <$> - for (Map.keys fsrcPaths) \fsrcPath -> + let foundFiles = Map.keys (Map.filter id fsrcPaths) in + for foundFiles \fsrcPath -> M.io (fingerprintFile fsrcPath) >>= \case - Left ioe -> otherIOError fsrcPath ioe - Right fp -> pure fp + Left ioe -> otherIOError fsrcPath ioe + Right fp -> pure fp -- | Scan the dependencies of a module. checkDeps :: @@ -186,3 +189,18 @@ checkDeps shouldLoad ds = Changed -> checkDeps True more Unchanged -> checkDeps shouldLoad more + +depMap :: Parsed -> Map P.ModName (Set P.ModName) +depMap xs = Map.fromList [(thing (P.mName k), Set.fromList [importedModule i | (i, _) <- v]) | (k, v) <- xs] + +loadOrder :: Map P.ModName (Set P.ModName) -> [P.ModName] -> [P.ModName] +loadOrder deps roots0 = snd (go Set.empty roots0) [] + where + go seen mms = + case mms of + [] -> (seen, id) + m : ms + | Set.member m seen -> go seen ms + | (seen1, out1) <- go (Set.insert m seen) (Set.toList (deps Map.! m)) + , (seen2, out2) <- go seen1 ms + -> (seen2, out1 . (m:) . out2) diff --git a/src/Cryptol/Project/Cache.hs b/src/Cryptol/Project/Cache.hs index 8d8538562..f387e941c 100644 --- a/src/Cryptol/Project/Cache.hs +++ b/src/Cryptol/Project/Cache.hs @@ -1,25 +1,89 @@ +{-# Language OverloadedStrings, BlockArguments #-} module Cryptol.Project.Cache where import Data.Map.Strict (Map) import qualified Data.Map.Strict as Map -import qualified Data.Text as Text +import qualified Data.Set as Set import qualified Data.Text.IO as Text import Data.Set (Set) -import Data.Maybe (fromMaybe) import System.Directory import System.FilePath as FP import System.IO.Error -import Text.Read (readMaybe) - +import qualified Toml +import qualified Toml.Schema as Toml +import Cryptol.ModuleSystem.Fingerprint ( Fingerprint ) import Cryptol.ModuleSystem.Env -import Cryptol.ModuleSystem.Fingerprint -- | The load cache. This is what persists across invocations. newtype LoadCache = LoadCache - { cacheFingerprints :: Map ModulePath FullFingerprint + { cacheFingerprints :: Map CacheModulePath FullFingerprint } deriving (Show, Read) +toCacheModulePath :: ModulePath -> CacheModulePath +toCacheModulePath mpath = + case mpath of + InMem x _ -> CacheInMem x + InFile x -> CacheInFile x + +data CacheModulePath + = CacheInMem String -- ^ module name + | CacheInFile FilePath -- ^ absolute file path + deriving (Show, Read, Ord, Eq) + +instance Toml.ToValue LoadCache where + toValue = Toml.defaultTableToValue + +instance Toml.ToTable LoadCache where + toTable x = Toml.table [ + "modules" Toml..= [ + Toml.table $ [ + case k of + CacheInFile a -> "file" Toml..= a + CacheInMem a -> "memory" Toml..= a, + "fingerprint" Toml..= moduleFingerprint v, + "foreign_fingerprints" Toml..= Set.toList (foreignFingerprints v), + "include_fingerprints" Toml..= [ + Toml.table [ + "file" Toml..= k1, + "fingerprint" Toml..= v1 + ] + | (k1, v1) <- Map.assocs (includeFingerprints v) + ] + ] ++ + [ "docstring_result" Toml..= result + | Just result <- [moduleDoctestResult v] + ] + | (k,v) <- Map.assocs (cacheFingerprints x) + ]] + +instance Toml.FromValue LoadCache where + fromValue = Toml.parseTableFromValue + do kvs <- Toml.reqKeyOf "modules" + $ Toml.listOf \ _ix -> + Toml.parseTableFromValue + do k <- Toml.pickKey [ + Toml.Key "memory" (fmap CacheInMem . Toml.fromValue), + Toml.Key "file" (fmap CacheInFile . Toml.fromValue) + ] + fp <- Toml.reqKey "fingerprint" + foreigns <- Toml.reqKey "foreign_fingerprints" + includes <- Toml.reqKeyOf "include_fingerprints" + $ Toml.listOf \ _ix -> + Toml.parseTableFromValue + $ (,) <$> Toml.reqKey "file" + <*> Toml.reqKey "fingerprint" + checkResult <- Toml.optKey "doctest_result" + pure (k, FullFingerprint + { moduleFingerprint = fp + , foreignFingerprints = Set.fromList foreigns + , includeFingerprints = Map.fromList includes + , moduleDoctestResult = checkResult + }) + pure LoadCache { + cacheFingerprints = Map.fromList kvs + } + -- | The full fingerprint hashes the module, but -- also the contents of included files and foreign libraries. @@ -27,6 +91,7 @@ data FullFingerprint = FullFingerprint { moduleFingerprint :: Fingerprint , includeFingerprints :: Map FilePath Fingerprint , foreignFingerprints :: Set Fingerprint + , moduleDoctestResult :: Maybe Bool -- ^ unknown, passed, failed } deriving (Eq, Show, Read) @@ -40,13 +105,13 @@ emptyLoadCache = LoadCache { cacheFingerprints = Map.empty } loadLoadCache :: IO LoadCache loadLoadCache = - do txt <- Text.readFile loadCachePath - pure $! fromMaybe emptyLoadCache (readMaybe (Text.unpack txt)) + do txt <- Text.readFile loadCachePath + case Toml.decode txt of + Toml.Success _ c -> pure c + Toml.Failure _ -> pure emptyLoadCache `catchIOError` \_ -> pure emptyLoadCache saveLoadCache :: LoadCache -> IO () saveLoadCache cache = do createDirectoryIfMissing False metaDir - writeFile loadCachePath (show cache) - - + writeFile loadCachePath (show (Toml.encode cache)) diff --git a/src/Cryptol/Project/Monad.hs b/src/Cryptol/Project/Monad.hs index e92998bbb..154090a31 100644 --- a/src/Cryptol/Project/Monad.hs +++ b/src/Cryptol/Project/Monad.hs @@ -5,7 +5,6 @@ module Cryptol.Project.Monad ( LoadM, Err, NoErr , ScanStatus(..), ChangeStatus(..), InvalidStatus(..), Parsed - , ppScanStatus , runLoadM , doModule , doModuleNonFail @@ -55,10 +54,12 @@ type Parsed = [ (Module PName, [(ImportSource, ModulePath)]) ] data ScanStatus = Scanned ChangeStatus FullFingerprint Parsed | Invalid InvalidStatus + deriving Show data ChangeStatus = Changed -- ^ The module, or one of its dependencies changed. | Unchanged -- ^ The module did not change. + deriving Show data InvalidStatus = InvalidModule ModuleError @@ -66,27 +67,14 @@ data InvalidStatus = | InvalidDep ImportSource ModulePath -- ^ Error in one of our dependencies - - - -ppScanStatus :: ScanStatus -> String -ppScanStatus status = - case status of - Scanned ch _ _ -> - case ch of - Unchanged -> "[Unchanged]" - Changed -> "[Changed ]" - Invalid reason -> - case reason of - InvalidModule {} -> "[Invalid ]" - InvalidDep {} -> "[InvalidD ]" + deriving Show data LoadState = LoadState { findModuleCache :: Map (ModName, [FilePath]) ModulePath -- ^ Map (module name, search path) -> module path - , fingerprints :: Map ModulePath FullFingerprint + , fingerprints :: Map CacheModulePath FullFingerprint -- ^ Hashes of known things. , scanned :: Map ModulePath ScanStatus @@ -142,7 +130,7 @@ liftCallback f (LoadM m) = runLoadM :: Config -> LoadM NoErr () -> - M.ModuleM (Map ModulePath FullFingerprint, Map ModulePath ScanStatus) + M.ModuleM (Map CacheModulePath FullFingerprint, Map ModulePath ScanStatus) runLoadM cfg (LoadM m) = do loadCfg <- M.io @@ -161,7 +149,7 @@ runLoadM cfg (LoadM m) = addFingerprint :: ModulePath -> FullFingerprint -> LoadM any () addFingerprint mpath fp = LoadM - (modify' \ls -> ls { fingerprints = Map.insert mpath fp (fingerprints ls) }) + (modify' \ls -> ls { fingerprints = Map.insert (toCacheModulePath mpath) fp (fingerprints ls) }) -- | Add information about the status of a module path. @@ -184,7 +172,7 @@ getModulePathLabel mpath = -- | Get the fingerprint for the given module path. getCachedFingerprint :: ModulePath -> LoadM any (Maybe FullFingerprint) getCachedFingerprint mpath = - LoadM (asks (Map.lookup mpath . cacheFingerprints . loadCache)) + LoadM (asks (Map.lookup (toCacheModulePath mpath) . cacheFingerprints . loadCache)) -- | Module path for the given import @@ -210,6 +198,6 @@ getStatus mpath = LoadM (gets (Map.lookup mpath . scanned)) -- | Get the fingerpint for the ginve path, if any. getFingerprint :: ModulePath -> LoadM any (Maybe FullFingerprint) -getFingerprint mpath = LoadM (gets (Map.lookup mpath . fingerprints)) +getFingerprint mpath = LoadM (gets (Map.lookup (toCacheModulePath mpath) . fingerprints)) diff --git a/src/Cryptol/REPL/Command.hs b/src/Cryptol/REPL/Command.hs index 9c9019bdc..7e54dc5a9 100644 --- a/src/Cryptol/REPL/Command.hs +++ b/src/Cryptol/REPL/Command.hs @@ -61,6 +61,8 @@ module Cryptol.REPL.Command ( , replParse , liftModuleCmd , moduleCmdResult + + , loadProjectREPL ) where import Cryptol.REPL.Monad @@ -107,6 +109,7 @@ import Cryptol.Utils.PP hiding (()) import Cryptol.Utils.Panic(panic) import Cryptol.Utils.RecordMap import qualified Cryptol.Parser.AST as P +import qualified Cryptol.Project as Proj import qualified Cryptol.Transform.Specialize as S import Cryptol.Symbolic ( ProverCommand(..), QueryType(..) @@ -156,6 +159,7 @@ import Prelude.Compat import qualified Data.SBV.Internals as SBV (showTDiff) import Data.Foldable (foldl') +import qualified Cryptol.Project.Cache as Proj @@ -2187,53 +2191,89 @@ checkDocStringsCmd input pure emptyCommandResult { crSuccess = False } Just mn -> checkModName mn +countOutcomes :: [[SubcommandResult]] -> (Int, Int, Int) +countOutcomes = foldl' countOutcomes1 (0, 0, 0) where + countOutcomes1 (successes, nofences, failures) [] + = (successes, nofences + 1, failures) + countOutcomes1 acc result = foldl' countOutcomes2 acc result - countOutcomes :: [[SubcommandResult]] -> (Int, Int, Int) - countOutcomes = foldl' countOutcomes1 (0, 0, 0) - where - countOutcomes1 (successes, nofences, failures) [] - = (successes, nofences + 1, failures) - countOutcomes1 acc result = foldl' countOutcomes2 acc result - - countOutcomes2 (successes, nofences, failures) result - | crSuccess (srResult result) = (successes + 1, nofences, failures) - | otherwise = (successes, nofences, failures + 1) + countOutcomes2 (successes, nofences, failures) result + | crSuccess (srResult result) = (successes + 1, nofences, failures) + | otherwise = (successes, nofences, failures + 1) - checkModName :: P.ModName -> REPL CommandResult - checkModName mn = - do env <- getModuleEnv - case M.lookupModule mn env of +checkModName :: P.ModName -> REPL CommandResult +checkModName mn = + do env <- getModuleEnv + case M.lookupModule mn env of + Nothing -> + case M.lookupSignature mn env of Nothing -> - case M.lookupSignature mn env of - Nothing -> - do rPutStrLn ("Module " ++ show input ++ " is not loaded") - pure emptyCommandResult { crSuccess = False } - Just{} -> - do rPutStrLn "Skipping docstrings on interface module" - pure emptyCommandResult - - Just fe - | T.isParametrizedModule (M.lmdModule (M.lmData fe)) -> do - rPutStrLn "Skipping docstrings on parameterized module" + do rPutStrLn ("Module " ++ show mn ++ " is not loaded") + pure emptyCommandResult { crSuccess = False } + Just{} -> + do rPutStrLn "Skipping docstrings on interface module" pure emptyCommandResult + Just fe + | T.isParametrizedModule (M.lmdModule (M.lmData fe)) -> do + rPutStrLn "Skipping docstrings on parameterized module" + pure emptyCommandResult + | otherwise -> do + results <- checkDocStrings fe + let (successes, nofences, failures) = countOutcomes [concat (drFences r) | r <- results] + forM_ results $ \dr -> + unless (null (drFences dr)) $ + do rPutStrLn "" + rPutStrLn ("\nChecking " ++ show (pp (drName dr))) + forM_ (drFences dr) $ \fence -> + forM_ fence $ \line -> do + rPutStrLn "" + rPutStrLn (T.unpack (srInput line)) + rPutStr (srLog line) + rPutStrLn "" + rPutStrLn ("Successes: " ++ show successes ++ ", No fences: " ++ show nofences ++ ", Failures: " ++ show failures) + pure emptyCommandResult { crSuccess = failures == 0 } + +-- | Load a project. +-- Note that this does not update the Cryptol environment, it only updates +-- the project cache. +-- XXX: Probably should move this in REPL +loadProjectREPL :: Proj.Config -> REPL CommandResult +loadProjectREPL cfg = + do minp <- getModuleInput + (res, warnings) <- io $ M.runModuleM minp $ Proj.loadProject cfg + printModuleWarnings warnings + case res of + Left err -> + do names <- M.mctxNameDisp <$> getFocusedEnv + rPrint (pp (ModuleSystemError names err)) + pure emptyCommandResult { crSuccess = False } - | otherwise -> do - results <- checkDocStrings fe - let (successes, nofences, failures) = countOutcomes [concat (drFences r) | r <- results] - - forM_ results $ \dr -> - unless (null (drFences dr)) $ - do rPutStrLn "" - rPutStrLn ("\nChecking " ++ show (pp (drName dr))) - forM_ (drFences dr) $ \fence -> - forM_ fence $ \line -> do - rPutStrLn "" - rPutStrLn (T.unpack (srInput line)) - rPutStr (srLog line) - - rPutStrLn "" - rPutStrLn ("Successes: " ++ show successes ++ ", No fences: " ++ show nofences ++ ", Failures: " ++ show failures) - - pure emptyCommandResult { crSuccess = failures == 0 } + Right ((fps, mp),env) -> + do setModuleEnv env + + let needcheck = [(k, P.thing (P.mName m)) | (M.InFile k, Proj.Scanned Proj.Changed _ ((m,_):_)) <- Map.assocs mp] + + fps' <- + foldM (\acc (path, name) -> + do rPutStrLn ("Checking: " ++ show (pp name)) + checkRes <- checkModName name + let acc' = Map.adjust (\fp -> fp { Proj.moduleDoctestResult = Just (crSuccess checkRes) }) (Proj.CacheInFile path) acc + pure acc') + fps needcheck + + io (Proj.saveLoadCache (Proj.LoadCache fps')) + pure emptyCommandResult + +ppScanStatus :: Proj.ScanStatus -> String +ppScanStatus status = + case status of + Proj.Scanned ch _ _ -> + case ch of + Proj.Unchanged -> "[Unchanged]" + Proj.Changed -> "[Changed ]" + Proj.Invalid reason -> + case reason of + Proj.InvalidModule {} -> "[Invalid ]" + Proj.InvalidDep {} -> "[InvalidD ]" From 423c3df51acbed0855fb6949acec1578ae5da46d Mon Sep 17 00:00:00 2001 From: Eric Mertens Date: Mon, 16 Dec 2024 16:48:10 -0800 Subject: [PATCH 22/35] Cache docstring results --- cryptol.cabal | 2 +- src/Cryptol/Project.hs | 19 +++++----- src/Cryptol/Project/Cache.hs | 37 +++++++++++-------- src/Cryptol/Project/Monad.hs | 15 +++++--- src/Cryptol/REPL/Command.hs | 71 +++++++++++++++++++++++------------- 5 files changed, 87 insertions(+), 57 deletions(-) diff --git a/cryptol.cabal b/cryptol.cabal index b5017e089..587dc4b3e 100644 --- a/cryptol.cabal +++ b/cryptol.cabal @@ -54,7 +54,7 @@ library array >= 0.4, containers >= 0.5, criterion-measurement, - cryptohash-sha1 >= 0.11 && < 0.12, + cryptohash-sha256 >= 0.11 && < 0.12, deepseq >= 1.3, directory >= 1.2.2.0, exceptions, diff --git a/src/Cryptol/Project.hs b/src/Cryptol/Project.hs index 880d4d7cb..6f5a11911 100644 --- a/src/Cryptol/Project.hs +++ b/src/Cryptol/Project.hs @@ -33,14 +33,11 @@ import Cryptol.Parser.Position (Located(..)) -- | Load a project. -- Returns information about the modules that are part of the project. -loadProject :: Config -> M.ModuleM (Map CacheModulePath FullFingerprint, Map ModulePath ScanStatus) +loadProject :: Config -> M.ModuleM (Map CacheModulePath FullFingerprint, Map ModulePath ScanStatus, Map CacheModulePath (Maybe Bool)) loadProject cfg = - do (fps, statuses) <- runLoadM cfg (for_ (modules cfg) scanPath) - let cache = LoadCache { cacheFingerprints = fps } + do (fps, statuses, out) <- runLoadM cfg (for_ (modules cfg) scanPath >> getOldDocstringResults) let deps = depMap [p | Scanned _ _ ps <- Map.elems statuses, p <- ps] - let needLoad = [thing (P.mName m) | Scanned Changed _ ps <- Map.elems statuses, (m, _) <- ps] - let order = loadOrder deps needLoad let modDetails = Map.fromList [(thing (P.mName m), (m, mp, fp)) | (mp, Scanned _ fp ps) <- Map.assocs statuses, (m, _) <- ps] @@ -58,10 +55,13 @@ loadProject cfg = (moduleFingerprint fp) fingerprints m - (deps Map.! name) + (Map.findWithDefault mempty name deps) - M.io (saveLoadCache cache) - pure (fps, statuses) + let oldResults = + case out of + Left{} -> mempty + Right x -> x + pure (fps, statuses, oldResults) -------------------------------------------------------------------------------- @@ -148,7 +148,6 @@ doParse mpath = { moduleFingerprint = fiFingerprint fi , includeFingerprints = fiIncludeDeps fi , foreignFingerprints = foreignFps - , moduleDoctestResult = Nothing } ) addFingerprint mpath newFp @@ -201,6 +200,6 @@ loadOrder deps roots0 = snd (go Set.empty roots0) [] [] -> (seen, id) m : ms | Set.member m seen -> go seen ms - | (seen1, out1) <- go (Set.insert m seen) (Set.toList (deps Map.! m)) + | (seen1, out1) <- go (Set.insert m seen) (Set.toList (Map.findWithDefault mempty m deps)) , (seen2, out2) <- go seen1 ms -> (seen2, out1 . (m:) . out2) diff --git a/src/Cryptol/Project/Cache.hs b/src/Cryptol/Project/Cache.hs index f387e941c..1ec7e3338 100644 --- a/src/Cryptol/Project/Cache.hs +++ b/src/Cryptol/Project/Cache.hs @@ -16,7 +16,7 @@ import Cryptol.ModuleSystem.Env -- | The load cache. This is what persists across invocations. newtype LoadCache = LoadCache - { cacheFingerprints :: Map CacheModulePath FullFingerprint + { cacheModules :: Map CacheModulePath CacheEntry } deriving (Show, Read) @@ -41,20 +41,21 @@ instance Toml.ToTable LoadCache where case k of CacheInFile a -> "file" Toml..= a CacheInMem a -> "memory" Toml..= a, - "fingerprint" Toml..= moduleFingerprint v, - "foreign_fingerprints" Toml..= Set.toList (foreignFingerprints v), + "fingerprint" Toml..= moduleFingerprint fp, + "foreign_fingerprints" Toml..= Set.toList (foreignFingerprints fp), "include_fingerprints" Toml..= [ Toml.table [ "file" Toml..= k1, "fingerprint" Toml..= v1 ] - | (k1, v1) <- Map.assocs (includeFingerprints v) + | (k1, v1) <- Map.assocs (includeFingerprints fp) ] ] ++ [ "docstring_result" Toml..= result - | Just result <- [moduleDoctestResult v] + | Just result <- [cacheDocstringResult v] ] - | (k,v) <- Map.assocs (cacheFingerprints x) + | (k,v) <- Map.assocs (cacheModules x) + , let fp = cacheFingerprint v ]] instance Toml.FromValue LoadCache where @@ -73,17 +74,24 @@ instance Toml.FromValue LoadCache where Toml.parseTableFromValue $ (,) <$> Toml.reqKey "file" <*> Toml.reqKey "fingerprint" - checkResult <- Toml.optKey "doctest_result" - pure (k, FullFingerprint - { moduleFingerprint = fp - , foreignFingerprints = Set.fromList foreigns - , includeFingerprints = Map.fromList includes - , moduleDoctestResult = checkResult + checkResult <- Toml.optKey "docstring_result" + pure (k, CacheEntry + { cacheFingerprint = FullFingerprint + { moduleFingerprint = fp + , foreignFingerprints = Set.fromList foreigns + , includeFingerprints = Map.fromList includes + } + , cacheDocstringResult = checkResult }) pure LoadCache { - cacheFingerprints = Map.fromList kvs + cacheModules = Map.fromList kvs } +data CacheEntry = CacheEntry + { cacheFingerprint :: FullFingerprint + , cacheDocstringResult :: Maybe Bool + } + deriving (Show, Read) -- | The full fingerprint hashes the module, but -- also the contents of included files and foreign libraries. @@ -91,7 +99,6 @@ data FullFingerprint = FullFingerprint { moduleFingerprint :: Fingerprint , includeFingerprints :: Map FilePath Fingerprint , foreignFingerprints :: Set Fingerprint - , moduleDoctestResult :: Maybe Bool -- ^ unknown, passed, failed } deriving (Eq, Show, Read) @@ -101,7 +108,7 @@ metaDir = ".cryproject" loadCachePath = metaDir FP. "loadcache" emptyLoadCache :: LoadCache -emptyLoadCache = LoadCache { cacheFingerprints = Map.empty } +emptyLoadCache = LoadCache { cacheModules = mempty } loadLoadCache :: IO LoadCache loadLoadCache = diff --git a/src/Cryptol/Project/Monad.hs b/src/Cryptol/Project/Monad.hs index 154090a31..81256ebec 100644 --- a/src/Cryptol/Project/Monad.hs +++ b/src/Cryptol/Project/Monad.hs @@ -19,6 +19,7 @@ module Cryptol.Project.Monad , getStatus , getFingerprint , lPutStrLn + , getOldDocstringResults ) where import Data.Map.Strict (Map) @@ -129,8 +130,8 @@ liftCallback f (LoadM m) = -- | Run a LoadM computation using the given configuration. runLoadM :: Config -> - LoadM NoErr () -> - M.ModuleM (Map CacheModulePath FullFingerprint, Map ModulePath ScanStatus) + LoadM NoErr a -> + M.ModuleM (Map CacheModulePath FullFingerprint, Map ModulePath ScanStatus, Either ModuleError a) runLoadM cfg (LoadM m) = do loadCfg <- M.io @@ -143,8 +144,8 @@ runLoadM cfg (LoadM m) = , fingerprints = mempty , scanned = mempty } - s <- execStateT (runExceptT (runReaderT m loadCfg)) loadState - pure (fingerprints s, scanned s) + (result, s) <- runStateT (runExceptT (runReaderT m loadCfg)) loadState + pure (fingerprints s, scanned s, result) addFingerprint :: ModulePath -> FullFingerprint -> LoadM any () addFingerprint mpath fp = @@ -172,7 +173,7 @@ getModulePathLabel mpath = -- | Get the fingerprint for the given module path. getCachedFingerprint :: ModulePath -> LoadM any (Maybe FullFingerprint) getCachedFingerprint mpath = - LoadM (asks (Map.lookup (toCacheModulePath mpath) . cacheFingerprints . loadCache)) + LoadM (asks (fmap cacheFingerprint . Map.lookup (toCacheModulePath mpath) . cacheModules . loadCache)) -- | Module path for the given import @@ -200,4 +201,6 @@ getStatus mpath = LoadM (gets (Map.lookup mpath . scanned)) getFingerprint :: ModulePath -> LoadM any (Maybe FullFingerprint) getFingerprint mpath = LoadM (gets (Map.lookup (toCacheModulePath mpath) . fingerprints)) - +getOldDocstringResults :: LoadM any (Map CacheModulePath (Maybe Bool)) +getOldDocstringResults = + LoadM (asks (fmap cacheDocstringResult . cacheModules . loadCache)) diff --git a/src/Cryptol/REPL/Command.hs b/src/Cryptol/REPL/Command.hs index 7e54dc5a9..0d315c2d0 100644 --- a/src/Cryptol/REPL/Command.hs +++ b/src/Cryptol/REPL/Command.hs @@ -2238,7 +2238,6 @@ checkModName mn = -- | Load a project. -- Note that this does not update the Cryptol environment, it only updates -- the project cache. --- XXX: Probably should move this in REPL loadProjectREPL :: Proj.Config -> REPL CommandResult loadProjectREPL cfg = do minp <- getModuleInput @@ -2250,30 +2249,52 @@ loadProjectREPL cfg = rPrint (pp (ModuleSystemError names err)) pure emptyCommandResult { crSuccess = False } - Right ((fps, mp),env) -> + Right ((fps, mp, docstringResults),env) -> do setModuleEnv env + let cache0 = fmap (\fp -> Proj.CacheEntry { cacheDocstringResult = Nothing, cacheFingerprint = fp }) fps + (cache, success) <- + foldM (\(fpAcc, success) (k, v) -> + case k of + M.InMem{} -> pure (fpAcc, success) + M.InFile path -> + case v of + Proj.Invalid e -> + do rPutStrLn ("Failed to process module: " ++ path ++ ":\n" ++ ppInvalidStatus e) + pure (fpAcc, False) -- report failure + Proj.Scanned Proj.Unchanged _ ((m,_):_) -> + do let name = P.thing (P.mName m) + rPutStrLn ("Skipping unmodified module: " ++ show (pp name)) + let prevResult = join (Map.lookup (Proj.CacheInFile path) docstringResults) + let fpAcc' = Map.adjust (\e -> e{ Proj.cacheDocstringResult = prevResult }) (Proj.CacheInFile path) fpAcc + pure (fpAcc', success) -- preserve success + Proj.Scanned Proj.Changed _ ((m,_):_) -> + do let name = P.thing (P.mName m) + rPutStrLn ("Checking docstrings on changed module: " ++ show (pp name)) + checkRes <- checkModName name + let fpAcc' = Map.adjust (\fp -> fp { Proj.cacheDocstringResult = Just (crSuccess checkRes) }) (Proj.CacheInFile path) fpAcc + pure (fpAcc', success && crSuccess checkRes) + Proj.Scanned _ _ [] -> panic "Cryptol.REPL.Command" ["malformed change entry"] + + ) (cache0, True) (Map.assocs mp) + + let (passing, failing, missing) = + foldl + (\(a,b,c) x -> + case Proj.cacheDocstringResult x of + Nothing -> (a,b,c+1) + Just True -> (a+1,b,c) + Just False -> (a,b+1,c)) + (0::Int,0::Int,0::Int) (Map.elems cache) + + rPutStrLn ("Passing: " ++ show passing ++ " Failing: " ++ show failing ++ " Missing: " ++ show missing) + + io (Proj.saveLoadCache (Proj.LoadCache cache)) + pure emptyCommandResult { crSuccess = success } - let needcheck = [(k, P.thing (P.mName m)) | (M.InFile k, Proj.Scanned Proj.Changed _ ((m,_):_)) <- Map.assocs mp] - - fps' <- - foldM (\acc (path, name) -> - do rPutStrLn ("Checking: " ++ show (pp name)) - checkRes <- checkModName name - let acc' = Map.adjust (\fp -> fp { Proj.moduleDoctestResult = Just (crSuccess checkRes) }) (Proj.CacheInFile path) acc - pure acc') - fps needcheck - - io (Proj.saveLoadCache (Proj.LoadCache fps')) - pure emptyCommandResult +ppInvalidStatus :: Proj.InvalidStatus -> String +ppInvalidStatus = \case + Proj.InvalidModule modErr -> indentStr (show (pp modErr)) + Proj.InvalidDep d _ -> indentStr ("Error in dependency: " ++ show (pp d)) -ppScanStatus :: Proj.ScanStatus -> String -ppScanStatus status = - case status of - Proj.Scanned ch _ _ -> - case ch of - Proj.Unchanged -> "[Unchanged]" - Proj.Changed -> "[Changed ]" - Proj.Invalid reason -> - case reason of - Proj.InvalidModule {} -> "[Invalid ]" - Proj.InvalidDep {} -> "[InvalidD ]" +indentStr :: String -> String +indentStr = unlines . map (" "++) . lines From e1538d98069889b820132cc22640996e1d6c30f5 Mon Sep 17 00:00:00 2001 From: Eric Mertens Date: Mon, 16 Dec 2024 17:07:17 -0800 Subject: [PATCH 23/35] update mtl version bound --- cabal.GHC-9.4.8.config | 2 +- cryptol.cabal | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cabal.GHC-9.4.8.config b/cabal.GHC-9.4.8.config index 9e81fe35b..7a45db1ad 100644 --- a/cabal.GHC-9.4.8.config +++ b/cabal.GHC-9.4.8.config @@ -182,7 +182,7 @@ constraints: any.BoundedChan ==1.0.3.0, mod +semirings +vector, any.monad-control ==1.0.3.1, any.monadLib ==3.10.1, - any.mtl ==2.2.2, + any.mtl ==2.3.1, any.mwc-random ==0.15.0.2, any.network ==3.1.4.0, network -devel, diff --git a/cryptol.cabal b/cryptol.cabal index 587dc4b3e..c78744807 100644 --- a/cryptol.cabal +++ b/cryptol.cabal @@ -84,7 +84,7 @@ library toml-parser >= 2.0 && <2.1, transformers-base >= 0.4, vector, - mtl >= 2.2.1, + mtl >= 2.3.1, time >= 1.6.0.1, panic >= 0.3, what4 >= 1.4 && < 1.7 From 1cd50c3e1eb89f3f0cf6e0c8da7cf6185123bcd9 Mon Sep 17 00:00:00 2001 From: Eric Mertens Date: Mon, 16 Dec 2024 17:32:47 -0800 Subject: [PATCH 24/35] update json rendering to include fingerprints --- cryptol-remote-api/src/CryptolServer/Exceptions.hs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cryptol-remote-api/src/CryptolServer/Exceptions.hs b/cryptol-remote-api/src/CryptolServer/Exceptions.hs index b6af366ba..f2fc91672 100644 --- a/cryptol-remote-api/src/CryptolServer/Exceptions.hs +++ b/cryptol-remote-api/src/CryptolServer/Exceptions.hs @@ -57,17 +57,19 @@ cryptolError modErr warns = CantFindFile path -> (20050, [ ("path", jsonString path) ]) - BadUtf8 path ue -> + BadUtf8 path fp ue -> (20010, [ ("path", jsonShow path) , ("error", jsonShow ue) + , ("fingerprint", jsonShow fp) ]) OtherIOError path exn -> (20060, [ ("path", jsonString path) , ("error", jsonShow exn) ]) - ModuleParseError source message -> + ModuleParseError source fp message -> (20540, [ ("source", jsonShow source) , ("error", jsonShow message) + , ("fingerprint", jsonShow fp) ]) RecursiveModules mods -> (20550, [ ("modules", jsonList (reverse (map jsonPretty mods))) From 8a68c0814cb9143c0361e862d1d2f779232cb8b6 Mon Sep 17 00:00:00 2001 From: Eric Mertens Date: Tue, 17 Dec 2024 09:32:09 -0800 Subject: [PATCH 25/35] backport tryError --- cabal.GHC-9.4.8.config | 2 +- cabal.GHC-9.6.5.config | 2 +- cabal.GHC-9.8.2.config | 2 +- cryptol.cabal | 2 +- src/Cryptol/Project/Monad.hs | 6 +++++- 5 files changed, 9 insertions(+), 5 deletions(-) diff --git a/cabal.GHC-9.4.8.config b/cabal.GHC-9.4.8.config index 7a45db1ad..9e81fe35b 100644 --- a/cabal.GHC-9.4.8.config +++ b/cabal.GHC-9.4.8.config @@ -182,7 +182,7 @@ constraints: any.BoundedChan ==1.0.3.0, mod +semirings +vector, any.monad-control ==1.0.3.1, any.monadLib ==3.10.1, - any.mtl ==2.3.1, + any.mtl ==2.2.2, any.mwc-random ==0.15.0.2, any.network ==3.1.4.0, network -devel, diff --git a/cabal.GHC-9.6.5.config b/cabal.GHC-9.6.5.config index 21d314ae2..7915b6bb0 100644 --- a/cabal.GHC-9.6.5.config +++ b/cabal.GHC-9.6.5.config @@ -180,7 +180,7 @@ constraints: any.BoundedChan ==1.0.3.0, mod +semirings +vector, any.monad-control ==1.0.3.1, any.monadLib ==3.10.1, - any.mtl ==2.3.1, + any.mtl ==2.2.1, any.mwc-random ==0.15.0.2, any.network ==3.1.4.0, network -devel, diff --git a/cabal.GHC-9.8.2.config b/cabal.GHC-9.8.2.config index 50585c685..76b3d2a8a 100644 --- a/cabal.GHC-9.8.2.config +++ b/cabal.GHC-9.8.2.config @@ -180,7 +180,7 @@ constraints: any.BoundedChan ==1.0.3.0, mod +semirings +vector, any.monad-control ==1.0.3.1, any.monadLib ==3.10.1, - any.mtl ==2.3.1, + any.mtl ==2.2.1, any.mwc-random ==0.15.0.2, any.network ==3.1.4.0, network -devel, diff --git a/cryptol.cabal b/cryptol.cabal index c78744807..587dc4b3e 100644 --- a/cryptol.cabal +++ b/cryptol.cabal @@ -84,7 +84,7 @@ library toml-parser >= 2.0 && <2.1, transformers-base >= 0.4, vector, - mtl >= 2.3.1, + mtl >= 2.2.1, time >= 1.6.0.1, panic >= 0.3, what4 >= 1.4 && < 1.7 diff --git a/src/Cryptol/Project/Monad.hs b/src/Cryptol/Project/Monad.hs index 81256ebec..1d7998c6a 100644 --- a/src/Cryptol/Project/Monad.hs +++ b/src/Cryptol/Project/Monad.hs @@ -26,7 +26,7 @@ import Data.Map.Strict (Map) import qualified Data.Map.Strict as Map import Control.Monad.Reader import Control.Monad.State -import Control.Monad.Except +import Control.Monad.Except hiding (tryError) import System.Directory import System.FilePath (makeRelative) @@ -112,6 +112,10 @@ doIO m = doModule (M.io m) tryLoadM :: LoadM Err a -> LoadM any (Either M.ModuleError a) tryLoadM (LoadM m) = LoadM (tryError m) +-- Introduced in mtl-2.3.1 which we can't rely upon yet +tryError :: MonadError e m => m a -> m (Either e a) +tryError action = (Right <$> action) `catchError` (pure . Left) + -- | Print a line lPutStrLn :: String -> LoadM any () lPutStrLn msg = doModuleNonFail (withLogger logPutStrLn msg) From 13ff72a3573aaf4790532cd8b8dd88d6bce4ac79 Mon Sep 17 00:00:00 2001 From: Eric Mertens Date: Tue, 17 Dec 2024 10:12:54 -0800 Subject: [PATCH 26/35] restore mtl version for the recent GHCs --- cabal.GHC-9.6.5.config | 2 +- cabal.GHC-9.8.2.config | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cabal.GHC-9.6.5.config b/cabal.GHC-9.6.5.config index 7915b6bb0..21d314ae2 100644 --- a/cabal.GHC-9.6.5.config +++ b/cabal.GHC-9.6.5.config @@ -180,7 +180,7 @@ constraints: any.BoundedChan ==1.0.3.0, mod +semirings +vector, any.monad-control ==1.0.3.1, any.monadLib ==3.10.1, - any.mtl ==2.2.1, + any.mtl ==2.3.1, any.mwc-random ==0.15.0.2, any.network ==3.1.4.0, network -devel, diff --git a/cabal.GHC-9.8.2.config b/cabal.GHC-9.8.2.config index 76b3d2a8a..50585c685 100644 --- a/cabal.GHC-9.8.2.config +++ b/cabal.GHC-9.8.2.config @@ -180,7 +180,7 @@ constraints: any.BoundedChan ==1.0.3.0, mod +semirings +vector, any.monad-control ==1.0.3.1, any.monadLib ==3.10.1, - any.mtl ==2.2.1, + any.mtl ==2.3.1, any.mwc-random ==0.15.0.2, any.network ==3.1.4.0, network -devel, From 67a4d29dd27fd3d353b234465709a408be019635 Mon Sep 17 00:00:00 2001 From: Eric Mertens Date: Tue, 17 Dec 2024 16:50:38 -0800 Subject: [PATCH 27/35] fixup errors --- src/Cryptol/Project/Cache.hs | 2 +- src/Cryptol/Project/Config.hs | 7 +------ src/Cryptol/REPL/Command.hs | 17 +++++++---------- 3 files changed, 9 insertions(+), 17 deletions(-) diff --git a/src/Cryptol/Project/Cache.hs b/src/Cryptol/Project/Cache.hs index 1ec7e3338..542f3da23 100644 --- a/src/Cryptol/Project/Cache.hs +++ b/src/Cryptol/Project/Cache.hs @@ -105,7 +105,7 @@ data FullFingerprint = FullFingerprint -- XXX: This should probably be a parameter metaDir, loadCachePath :: FilePath metaDir = ".cryproject" -loadCachePath = metaDir FP. "loadcache" +loadCachePath = metaDir FP. "loadcache.toml" emptyLoadCache :: LoadCache emptyLoadCache = LoadCache { cacheModules = mempty } diff --git a/src/Cryptol/Project/Config.hs b/src/Cryptol/Project/Config.hs index 697b3cbee..d2fa7e9fb 100644 --- a/src/Cryptol/Project/Config.hs +++ b/src/Cryptol/Project/Config.hs @@ -37,10 +37,7 @@ data ConfigLoadErrorInfo instance PP ConfigLoadError where ppPrec _ (ConfigLoadError path info) = case info of - ConfigParseError errs -> text $ unlines errs -{- - show topMsg ++ prettyPosWithSource pos file "\nParse error:" ++ err --} + ConfigParseError errs -> text (unlines errs) SetRootFailed ioe -> hang topMsg 4 (hang "Failed to set project root:" @@ -63,5 +60,3 @@ loadConfig path = tryIOError do setCurrentDirectory (takeDirectory filePath FP. root config) pure config - - diff --git a/src/Cryptol/REPL/Command.hs b/src/Cryptol/REPL/Command.hs index 0d315c2d0..ab79307ba 100644 --- a/src/Cryptol/REPL/Command.hs +++ b/src/Cryptol/REPL/Command.hs @@ -1594,7 +1594,7 @@ getPrimMap = liftModuleCmd M.getPrimMap liftModuleCmd :: M.ModuleCmd a -> REPL a liftModuleCmd cmd = moduleCmdResult =<< io . cmd =<< getModuleInput --- TODO: add filter for my exhaustie prop guards warning here +-- TODO: add filter for my exhaustive prop guards warning here printModuleWarnings :: [M.ModuleWarning] -> REPL () printModuleWarnings ws0 = do @@ -2259,17 +2259,17 @@ loadProjectREPL cfg = M.InFile path -> case v of Proj.Invalid e -> - do rPutStrLn ("Failed to process module: " ++ path ++ ":\n" ++ ppInvalidStatus e) + do rPrint ("Failed to process module: " <> text path <> ":" $$ ppInvalidStatus e) pure (fpAcc, False) -- report failure Proj.Scanned Proj.Unchanged _ ((m,_):_) -> do let name = P.thing (P.mName m) - rPutStrLn ("Skipping unmodified module: " ++ show (pp name)) + rPrint ("Skipping unmodified module: " <> pp name) let prevResult = join (Map.lookup (Proj.CacheInFile path) docstringResults) let fpAcc' = Map.adjust (\e -> e{ Proj.cacheDocstringResult = prevResult }) (Proj.CacheInFile path) fpAcc pure (fpAcc', success) -- preserve success Proj.Scanned Proj.Changed _ ((m,_):_) -> do let name = P.thing (P.mName m) - rPutStrLn ("Checking docstrings on changed module: " ++ show (pp name)) + rPrint ("Checking docstrings on changed module: " <> pp name) checkRes <- checkModName name let fpAcc' = Map.adjust (\fp -> fp { Proj.cacheDocstringResult = Just (crSuccess checkRes) }) (Proj.CacheInFile path) fpAcc pure (fpAcc', success && crSuccess checkRes) @@ -2291,10 +2291,7 @@ loadProjectREPL cfg = io (Proj.saveLoadCache (Proj.LoadCache cache)) pure emptyCommandResult { crSuccess = success } -ppInvalidStatus :: Proj.InvalidStatus -> String +ppInvalidStatus :: Proj.InvalidStatus -> Doc ppInvalidStatus = \case - Proj.InvalidModule modErr -> indentStr (show (pp modErr)) - Proj.InvalidDep d _ -> indentStr ("Error in dependency: " ++ show (pp d)) - -indentStr :: String -> String -indentStr = unlines . map (" "++) . lines + Proj.InvalidModule modErr -> pp modErr + Proj.InvalidDep d _ -> "Error in dependency: " <> pp d From 233168cf0d7dda1d8979609132ba416131b9dcf7 Mon Sep 17 00:00:00 2001 From: Eric Mertens Date: Tue, 17 Dec 2024 16:56:35 -0800 Subject: [PATCH 28/35] Nicer error printing --- src/Cryptol/ModuleSystem/Base.hs | 3 +-- src/Cryptol/REPL/Command.hs | 3 ++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Cryptol/ModuleSystem/Base.hs b/src/Cryptol/ModuleSystem/Base.hs index e89939158..922b985bb 100644 --- a/src/Cryptol/ModuleSystem/Base.hs +++ b/src/Cryptol/ModuleSystem/Base.hs @@ -28,7 +28,6 @@ import qualified Data.List.NonEmpty as NE import Data.List.NonEmpty (NonEmpty(..)) import Data.Function(on) import Data.Monoid ((<>),Endo(..), Any(..)) -import qualified Data.Text as T import Data.Text.Encoding (decodeUtf8') import System.Directory (doesFileExist, canonicalizePath) import System.FilePath ( addExtension @@ -134,7 +133,7 @@ renameImpNameInCurrentEnv (P.ImpNested pname) = fail ("Undefined submodule name: " ++ show (pp pname)) _:_:_ -> do fail ("Ambiguous submodule name: " ++ show (pp pname)) - [name] -> pure (P.ImpNested name) + [n] -> pure (P.ImpNested n) -- NoPat ----------------------------------------------------------------------- diff --git a/src/Cryptol/REPL/Command.hs b/src/Cryptol/REPL/Command.hs index ab79307ba..2f4e3cec4 100644 --- a/src/Cryptol/REPL/Command.hs +++ b/src/Cryptol/REPL/Command.hs @@ -2259,7 +2259,8 @@ loadProjectREPL cfg = M.InFile path -> case v of Proj.Invalid e -> - do rPrint ("Failed to process module: " <> text path <> ":" $$ ppInvalidStatus e) + do rPrint ("Failed to process module:" <+> (text path <> ":") $$ + indent 2 (ppInvalidStatus e)) pure (fpAcc, False) -- report failure Proj.Scanned Proj.Unchanged _ ((m,_):_) -> do let name = P.thing (P.mName m) From ecfdd4c311cd2935fc988db082344169b7e72860 Mon Sep 17 00:00:00 2001 From: Eric Mertens Date: Wed, 18 Dec 2024 16:48:02 -0800 Subject: [PATCH 29/35] Add flag to explicitly refresh the project --- cryptol-repl-internal/REPL/Haskeline.hs | 10 +++++++--- cryptol/Main.hs | 9 +++++++++ src/Cryptol/Project.hs | 6 +++--- src/Cryptol/Project/Cache.hs | 4 +++- src/Cryptol/Project/Monad.hs | 5 +++-- src/Cryptol/REPL/Command.hs | 6 +++--- 6 files changed, 28 insertions(+), 12 deletions(-) diff --git a/cryptol-repl-internal/REPL/Haskeline.hs b/cryptol-repl-internal/REPL/Haskeline.hs index 8500eb9c6..ddd350e93 100644 --- a/cryptol-repl-internal/REPL/Haskeline.hs +++ b/cryptol-repl-internal/REPL/Haskeline.hs @@ -132,8 +132,12 @@ loadCryRC cryrc = else return status -- | Haskeline-specific repl implementation. -repl :: Cryptolrc -> Maybe Project.Config -> ReplMode -> Bool -> Bool -> REPL () -> IO CommandResult -repl cryrc projectConfig replMode callStacks stopOnError begin = +repl :: + Cryptolrc -> + Maybe Project.Config -> + Bool {- ^ refresh project -} -> + ReplMode -> Bool -> Bool -> REPL () -> IO CommandResult +repl cryrc projectConfig projectRefresh replMode callStacks stopOnError begin = runREPL isBatch callStacks stdoutLogger replAction where @@ -152,7 +156,7 @@ repl cryrc projectConfig replMode callStacks stopOnError begin = if crSuccess status then do begin case projectConfig of - Just config -> loadProjectREPL config + Just config -> loadProjectREPL projectRefresh config Nothing -> crySession replMode stopOnError else return status diff --git a/cryptol/Main.hs b/cryptol/Main.hs index bd5de9928..519d4bbc7 100644 --- a/cryptol/Main.hs +++ b/cryptol/Main.hs @@ -51,6 +51,7 @@ data Options = Options , optHelp :: Bool , optBatch :: ReplMode , optProject :: Maybe FilePath + , optProjectRefresh :: Bool , optCallStacks :: Bool , optCommands :: [String] , optColorMode :: ColorMode @@ -67,6 +68,7 @@ defaultOptions = Options , optHelp = False , optBatch = InteractiveRepl , optProject = Nothing + , optProjectRefresh = False , optCallStacks = True , optCommands = [] , optColorMode = AutoColor @@ -87,6 +89,9 @@ options = , Option "p" ["project"] (ReqArg setProject "CRYPROJECT") ("Load and verify a Cryptol project using the provided project " ++ "configuration file or directory containing 'cryproject.toml'") + + , Option "" ["refresh-project"] (NoArg setProjectRefresh) + "Ignore a pre-existing cache file when loading a project." , Option "e" ["stop-on-error"] (NoArg setStopOnError) "stop script execution as soon as an error occurs." @@ -149,6 +154,9 @@ setInteractiveBatchScript path = modify $ \ opts -> opts { optBatch = Interactiv setProject :: String -> OptParser Options setProject path = modify $ \opts -> opts { optProject = Just path } +setProjectRefresh :: OptParser Options +setProjectRefresh = modify $ \opts -> opts { optProjectRefresh = True } + -- | Set the color mode of the terminal output. setColorMode :: String -> OptParser Options setColorMode "auto" = modify $ \ opts -> opts { optColorMode = AutoColor } @@ -240,6 +248,7 @@ main = do (opts'', mConfig) <- setupProject opts' status <- repl (optCryptolrc opts'') mConfig + (optProjectRefresh opts'') (optBatch opts'') (optCallStacks opts'') (optStopOnError opts'') diff --git a/src/Cryptol/Project.hs b/src/Cryptol/Project.hs index 6f5a11911..6b601afee 100644 --- a/src/Cryptol/Project.hs +++ b/src/Cryptol/Project.hs @@ -33,9 +33,9 @@ import Cryptol.Parser.Position (Located(..)) -- | Load a project. -- Returns information about the modules that are part of the project. -loadProject :: Config -> M.ModuleM (Map CacheModulePath FullFingerprint, Map ModulePath ScanStatus, Map CacheModulePath (Maybe Bool)) -loadProject cfg = - do (fps, statuses, out) <- runLoadM cfg (for_ (modules cfg) scanPath >> getOldDocstringResults) +loadProject :: Bool -> Config -> M.ModuleM (Map CacheModulePath FullFingerprint, Map ModulePath ScanStatus, Map CacheModulePath (Maybe Bool)) +loadProject refresh cfg = + do (fps, statuses, out) <- runLoadM refresh cfg (for_ (modules cfg) scanPath >> getOldDocstringResults) let deps = depMap [p | Scanned _ _ ps <- Map.elems statuses, p <- ps] let needLoad = [thing (P.mName m) | Scanned Changed _ ps <- Map.elems statuses, (m, _) <- ps] let order = loadOrder deps needLoad diff --git a/src/Cryptol/Project/Cache.hs b/src/Cryptol/Project/Cache.hs index 542f3da23..e9f251bdc 100644 --- a/src/Cryptol/Project/Cache.hs +++ b/src/Cryptol/Project/Cache.hs @@ -36,6 +36,7 @@ instance Toml.ToValue LoadCache where instance Toml.ToTable LoadCache where toTable x = Toml.table [ + "version" Toml..= (1 :: Int), -- increase this to invalidate old files "modules" Toml..= [ Toml.table $ [ case k of @@ -60,7 +61,8 @@ instance Toml.ToTable LoadCache where instance Toml.FromValue LoadCache where fromValue = Toml.parseTableFromValue - do kvs <- Toml.reqKeyOf "modules" + do 1 <- Toml.reqKey "version" :: Toml.ParseTable l Int + kvs <- Toml.reqKeyOf "modules" $ Toml.listOf \ _ix -> Toml.parseTableFromValue do k <- Toml.pickKey [ diff --git a/src/Cryptol/Project/Monad.hs b/src/Cryptol/Project/Monad.hs index 1d7998c6a..38d35cd43 100644 --- a/src/Cryptol/Project/Monad.hs +++ b/src/Cryptol/Project/Monad.hs @@ -133,14 +133,15 @@ liftCallback f (LoadM m) = -- | Run a LoadM computation using the given configuration. runLoadM :: + Bool {- ^ force a refresh -} -> Config -> LoadM NoErr a -> M.ModuleM (Map CacheModulePath FullFingerprint, Map ModulePath ScanStatus, Either ModuleError a) -runLoadM cfg (LoadM m) = +runLoadM refresh cfg (LoadM m) = do loadCfg <- M.io do path <- canonicalizePath (root cfg) - cache <- loadLoadCache + cache <- if refresh then pure emptyLoadCache else loadLoadCache pure LoadConfig { canonRoot = path , loadCache = cache } diff --git a/src/Cryptol/REPL/Command.hs b/src/Cryptol/REPL/Command.hs index 2f4e3cec4..587fe64d4 100644 --- a/src/Cryptol/REPL/Command.hs +++ b/src/Cryptol/REPL/Command.hs @@ -2238,10 +2238,10 @@ checkModName mn = -- | Load a project. -- Note that this does not update the Cryptol environment, it only updates -- the project cache. -loadProjectREPL :: Proj.Config -> REPL CommandResult -loadProjectREPL cfg = +loadProjectREPL :: Bool -> Proj.Config -> REPL CommandResult +loadProjectREPL refresh cfg = do minp <- getModuleInput - (res, warnings) <- io $ M.runModuleM minp $ Proj.loadProject cfg + (res, warnings) <- io $ M.runModuleM minp $ Proj.loadProject refresh cfg printModuleWarnings warnings case res of Left err -> From dd7dbf58517b3213ec6d793f7a0ebed8de990177 Mon Sep 17 00:00:00 2001 From: Eric Mertens Date: Wed, 18 Dec 2024 17:15:45 -0800 Subject: [PATCH 30/35] update fingerprint in test case --- cryptol-remote-api/python/tests/cryptol/test_filedeps.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cryptol-remote-api/python/tests/cryptol/test_filedeps.py b/cryptol-remote-api/python/tests/cryptol/test_filedeps.py index ddd66387e..0bd36436f 100644 --- a/cryptol-remote-api/python/tests/cryptol/test_filedeps.py +++ b/cryptol-remote-api/python/tests/cryptol/test_filedeps.py @@ -10,7 +10,7 @@ def test_FileDeps(self) -> None: connect(verify=False) path = str(Path('tests','cryptol','test-files','Id.cry')) result = file_deps(path,True) - self.assertEqual(result['fingerprint'],"8A49C6A461AF276DF56C4FE4279BCFC51D891214") + self.assertEqual(result['fingerprint'],"8316fb4e38d33ec3b9f89d355597c058b2e4baf653bf18dc4ead7e166a8a32f8") self.assertEqual(result['foreign'],[]) self.assertEqual(result['imports'],['Cryptol']) self.assertEqual(result['includes'],[]) From 6f296d2698cc2237394f21fa37fd313da99a43f5 Mon Sep 17 00:00:00 2001 From: Eric Mertens Date: Thu, 19 Dec 2024 09:51:42 -0800 Subject: [PATCH 31/35] Add project structure documentation --- docs/Project.md | 102 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 docs/Project.md diff --git a/docs/Project.md b/docs/Project.md new file mode 100644 index 000000000..91bf12449 --- /dev/null +++ b/docs/Project.md @@ -0,0 +1,102 @@ +# Project Files + +Cryptol supports specifying a *project* file that can accelerate the repeated +loading and testing of a large, interconnected set of source files. Cryptol +will remember the hashes of the files previously checked and use this to avoid +type-checking and testing files that are unchanged since the previous loading +of the project. + +To use this feature a `cryproject.toml` should be created in the root directory +of the cryptol source files. + +To check a whole project Cryptol can be invoked with the `--project` or `-p` +flag using the directory containing the project as an argument. + +Example: + +```shell +cryptol -p myproject/ +``` + +To discard the previous cached results and reload a whole project use +`--refresh-project`. This can be useful when versions of external tools +have changed or simply to get confidence that everything is still in a +working state. + +Example: + +```shell +cryptol -p myproject/ --refresh-project +``` + +## `cryproject.toml` Format + +Project files are described by a [TOML](https://toml.io/en/) file using the +following top-level key-value assignments: + +- `root` can optionally be specified to override the directory that Cryptol + files are located in. + +- `modules` is a list of filenames containing the leaf modules in a project. + These modules, and all of their dependencies, will be loaded when the project + is loaded. + +Example file: + +```toml +modules = [ + "Example/A.cry", + "Example/B.cry", +] +``` + +## `loadcache.toml` Format + +After loading a project a cache file is generated and stored in +`.cryproject/loadcache.toml`. This file contains a version number to allow +caches to automatically invalidate when the project subsystem updates. + +- `version` specifies the cache file format version in order to allow old + caches to be invalidated when Cryptol changes the meaning of this file. + +- `file` specifies the absolute path to a Cryptol module for those stored + in files. + +- `memory` specifies the module name of a primitive module built into Cryptol. + +- `fingerprint` specifies a SHA2-256 hash of the source file which is used to + detect when the source file has changed from the previous run. + +- `foreign_fingerprints` is a list of SHA2-256 hashes of shared libraries that + this Cryptol file directly includes. + +- `include_fingerprints` is a list of SHA2-256 hashes of pre-processor included + files that this Cryptol files directly includes. + +- `docstring_result` is a boolean `true` when `:check-docstrings` previously + succeeded for this module and `false` when it previously failed. It will be + missing if tests were never run on this module. + +```toml +version = 1 + +[[modules]] +fingerprint = "2f671b21f2933a006b6a843c7f281388e6b8227f9944b111f87711dc9ca8448f" +foreign_fingerprints = [] +include_fingerprints = [] +memory = "Cryptol" + +[[modules]] +docstring_result = true +file = "/path/to/project/Id.cry" +fingerprint = "a9e6f7a4b65ead6bd8e27442717d6b0dc54afc73e34b18c32f005ceb7a8f3c34" +foreign_fingerprints = [ "c7767a13281a56631c72b9b6f69a17746dc02213e7f2b24a8a4a6fe7afd9ee0a" ] +include_fingerprints = [] + +[[modules]] +docstring_result = true +file = "/path/to/project/Main.cry" +fingerprint = "6b36f965ebb1a68cf76d689a966806ec879540aa6576a76c1aaa7705a4af09d5" +foreign_fingerprints = [] +include_fingerprints = [] +``` From 7f4c6c09c3f1b65247a5ca634edf077dba06d67b Mon Sep 17 00:00:00 2001 From: Eric Mertens Date: Fri, 20 Dec 2024 08:57:54 -0800 Subject: [PATCH 32/35] test fixup --- tests/ffi/ffi-runtime-errors.icry.stdout | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/tests/ffi/ffi-runtime-errors.icry.stdout b/tests/ffi/ffi-runtime-errors.icry.stdout index 19f17e108..afb14ca1e 100644 --- a/tests/ffi/ffi-runtime-errors.icry.stdout +++ b/tests/ffi/ffi-runtime-errors.icry.stdout @@ -4,26 +4,22 @@ Loading module Main Loading dynamic library ffi-runtime-errors.so numeric type argument to foreign function is too large: 18446744073709551616 -in type parameter n`899 of function Main::f +in type parameter n`892 of function Main::f type arguments must fit in a C `size_t` -- Backtrace -- Main::f called at ffi-runtime-errors.icry:4:1--4:2 cannot call foreign function Main::g -FFI calls are not supported in this context -If you are trying to evaluate an expression, try rebuilding - Cryptol with FFI support enabled. +No foreign implementation is loaded, + or FFI calls are not supported in this context. cannot call foreign function Main::g -FFI calls are not supported in this context -If you are trying to evaluate an expression, try rebuilding - Cryptol with FFI support enabled. +No foreign implementation is loaded, + or FFI calls are not supported in this context. cannot call foreign function Main::g -FFI calls are not supported in this context -If you are trying to evaluate an expression, try rebuilding - Cryptol with FFI support enabled. + No foreign implementation is loaded, + or FFI calls are not supported in this context. cannot call foreign function Main::g -FFI calls are not supported in this context -If you are trying to evaluate an expression, try rebuilding - Cryptol with FFI support enabled. +No foreign implementation is loaded, + or FFI calls are not supported in this context. From 37addd375f07592dae9261735713f34f722f7226 Mon Sep 17 00:00:00 2001 From: Eric Mertens Date: Fri, 20 Dec 2024 09:29:31 -0800 Subject: [PATCH 33/35] test fixes --- src/Cryptol/ModuleSystem/Base.hs | 3 ++- tests/ffi/ffi-runtime-errors.icry.stdout | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Cryptol/ModuleSystem/Base.hs b/src/Cryptol/ModuleSystem/Base.hs index 922b985bb..f9a26a1bc 100644 --- a/src/Cryptol/ModuleSystem/Base.hs +++ b/src/Cryptol/ModuleSystem/Base.hs @@ -28,6 +28,7 @@ import qualified Data.List.NonEmpty as NE import Data.List.NonEmpty (NonEmpty(..)) import Data.Function(on) import Data.Monoid ((<>),Endo(..), Any(..)) +import qualified Data.Text as T import Data.Text.Encoding (decodeUtf8') import System.Directory (doesFileExist, canonicalizePath) import System.FilePath ( addExtension @@ -182,7 +183,7 @@ parseModule path = do let fp = fingerprint bytes txt <- case decodeUtf8' bytes of - Right txt -> return txt + Right txt -> return $! T.replace "\r\n" "\n" txt Left e -> badUtf8 path fp e diff --git a/tests/ffi/ffi-runtime-errors.icry.stdout b/tests/ffi/ffi-runtime-errors.icry.stdout index afb14ca1e..0ee2f7bf3 100644 --- a/tests/ffi/ffi-runtime-errors.icry.stdout +++ b/tests/ffi/ffi-runtime-errors.icry.stdout @@ -18,8 +18,8 @@ No foreign implementation is loaded, or FFI calls are not supported in this context. cannot call foreign function Main::g - No foreign implementation is loaded, - or FFI calls are not supported in this context. +No foreign implementation is loaded, + or FFI calls are not supported in this context. cannot call foreign function Main::g No foreign implementation is loaded, or FFI calls are not supported in this context. From c9719a544e4770f72771bf90b2a2e4e72aa76e58 Mon Sep 17 00:00:00 2001 From: Eric Mertens Date: Fri, 20 Dec 2024 11:00:30 -0800 Subject: [PATCH 34/35] incorporate project documentation info refman --- docs/Project.md | 102 ---------------------------- docs/RefMan/Project.rst | 132 ++++++++++++++++++++++++++++++++++++ docs/RefMan/RefMan.rst | 1 + src/Cryptol/REPL/Command.hs | 7 +- 4 files changed, 138 insertions(+), 104 deletions(-) delete mode 100644 docs/Project.md create mode 100644 docs/RefMan/Project.rst diff --git a/docs/Project.md b/docs/Project.md deleted file mode 100644 index 91bf12449..000000000 --- a/docs/Project.md +++ /dev/null @@ -1,102 +0,0 @@ -# Project Files - -Cryptol supports specifying a *project* file that can accelerate the repeated -loading and testing of a large, interconnected set of source files. Cryptol -will remember the hashes of the files previously checked and use this to avoid -type-checking and testing files that are unchanged since the previous loading -of the project. - -To use this feature a `cryproject.toml` should be created in the root directory -of the cryptol source files. - -To check a whole project Cryptol can be invoked with the `--project` or `-p` -flag using the directory containing the project as an argument. - -Example: - -```shell -cryptol -p myproject/ -``` - -To discard the previous cached results and reload a whole project use -`--refresh-project`. This can be useful when versions of external tools -have changed or simply to get confidence that everything is still in a -working state. - -Example: - -```shell -cryptol -p myproject/ --refresh-project -``` - -## `cryproject.toml` Format - -Project files are described by a [TOML](https://toml.io/en/) file using the -following top-level key-value assignments: - -- `root` can optionally be specified to override the directory that Cryptol - files are located in. - -- `modules` is a list of filenames containing the leaf modules in a project. - These modules, and all of their dependencies, will be loaded when the project - is loaded. - -Example file: - -```toml -modules = [ - "Example/A.cry", - "Example/B.cry", -] -``` - -## `loadcache.toml` Format - -After loading a project a cache file is generated and stored in -`.cryproject/loadcache.toml`. This file contains a version number to allow -caches to automatically invalidate when the project subsystem updates. - -- `version` specifies the cache file format version in order to allow old - caches to be invalidated when Cryptol changes the meaning of this file. - -- `file` specifies the absolute path to a Cryptol module for those stored - in files. - -- `memory` specifies the module name of a primitive module built into Cryptol. - -- `fingerprint` specifies a SHA2-256 hash of the source file which is used to - detect when the source file has changed from the previous run. - -- `foreign_fingerprints` is a list of SHA2-256 hashes of shared libraries that - this Cryptol file directly includes. - -- `include_fingerprints` is a list of SHA2-256 hashes of pre-processor included - files that this Cryptol files directly includes. - -- `docstring_result` is a boolean `true` when `:check-docstrings` previously - succeeded for this module and `false` when it previously failed. It will be - missing if tests were never run on this module. - -```toml -version = 1 - -[[modules]] -fingerprint = "2f671b21f2933a006b6a843c7f281388e6b8227f9944b111f87711dc9ca8448f" -foreign_fingerprints = [] -include_fingerprints = [] -memory = "Cryptol" - -[[modules]] -docstring_result = true -file = "/path/to/project/Id.cry" -fingerprint = "a9e6f7a4b65ead6bd8e27442717d6b0dc54afc73e34b18c32f005ceb7a8f3c34" -foreign_fingerprints = [ "c7767a13281a56631c72b9b6f69a17746dc02213e7f2b24a8a4a6fe7afd9ee0a" ] -include_fingerprints = [] - -[[modules]] -docstring_result = true -file = "/path/to/project/Main.cry" -fingerprint = "6b36f965ebb1a68cf76d689a966806ec879540aa6576a76c1aaa7705a4af09d5" -foreign_fingerprints = [] -include_fingerprints = [] -``` diff --git a/docs/RefMan/Project.rst b/docs/RefMan/Project.rst new file mode 100644 index 000000000..3092dde07 --- /dev/null +++ b/docs/RefMan/Project.rst @@ -0,0 +1,132 @@ +Project Files +============= + +Cryptol supports specifying a *project* file that can accelerate the +repeated loading and testing of a large, interconnected set of source +files. Cryptol will remember the hashes of the files previously checked +and use this to avoid type-checking and testing files that are unchanged +since the previous loading of the project. + +To use this feature a ``cryproject.toml`` should be created in the root +directory of the cryptol source files that lists all of the top-level +modules of the project. The dependencies of these modules will implicitly +be added to the project. + +To check a whole project, Cryptol can be invoked with the ``--project`` +or ``-p`` flag using the directory containing the project as an +argument. This will type-check all of the modules in the project and +check the docstrings for all modules in the project. + +All errors are reported to stdout. When all modules load and all tests +pass cryptol's exit code will be ``0``. When the project does not load +successfully the exit code is ``1``. + +After loading a project the cache information is saved into a Cryptol- +managed file in the project root directory ``.cryproject/loadcache.toml``. + +Example: + +.. code:: shell + + cryptol -p myproject/ + +To discard the previous cached results and reload a whole project use +``--refresh-project``. This can be useful when versions of external +tools have changed or simply to get confidence that everything is still +in a working state. + +Example: + +.. code:: shell + + cryptol -p myproject/ --refresh-project + +``cryproject.toml`` Format +-------------------------- + +Project files are described by a `TOML `__ file +using the following top-level key-value assignments: + +- ``root`` - *optional* - *string* - can optionally be specified to override the directory that + Cryptol files are located in. Otherwise modules are loaded relative + to the directory containing the ``cryproject.toml``. + +- ``modules`` - *required* - *list of strings* - is a list of filenames containing the top-level modules in a + project. These modules, and all of their dependencies, will be loaded + when the project is loaded. + +Example directory structure: + +.. code:: + + project + ├── Id.c + ├── Id.cry + ├── Id.dylib + ├── Main.cry + └── cryproject.toml + +Example ``cryproject.toml``: + +.. code:: toml + + modules = [ + "Id.cry", + "Main.cry", + ] + +``loadcache.toml`` Format +------------------------- + +After loading a project a cache file is generated and stored in +``.cryproject/loadcache.toml``. This file contains a version number to +allow caches to automatically invalidate when the project subsystem +updates. Modules that fail to load at all are not listed in the cache +file and will be reprocessed on subsequent project loads even if unchanged. + +- ``version`` - *integer* - specifies the cache file format version in order to allow + old caches to be invalidated when Cryptol changes the meaning of this + file. + +- ``file`` - *string* - specifies the absolute path to a Cryptol module for those + stored in files. + +- ``memory`` - *string* - specifies the module name of a primitive module built into + Cryptol. + +- ``fingerprint`` - *string* - specifies a SHA2-256 hash of the source file which is + used to detect when the source file has changed from the previous run. + +- ``foreign_fingerprints`` - *list of string* - is a list of SHA2-256 hashes of dynamic + libraries that this Cryptol file directly loads. + +- ``include_fingerprints`` - *list of string* - is a list of SHA2-256 hashes of pre-processor + included files that this Cryptol files directly includes. + +- ``docstring_result`` - *boolean* - is ``true`` when ``:check-docstrings`` + previously succeeded for this module and ``false`` when it previously + failed. It will be missing if tests were never run on this module. + +.. code:: toml + + version = 1 + + [[modules]] + fingerprint = "2f671b21f2933a006b6a843c7f281388e6b8227f9944b111f87711dc9ca8448f" + foreign_fingerprints = [] + include_fingerprints = [] + memory = "Cryptol" + + [[modules]] + docstring_result = true + file = "/path/to/project/Id.cry" + fingerprint = "a9e6f7a4b65ead6bd8e27442717d6b0dc54afc73e34b18c32f005ceb7a8f3c34" + foreign_fingerprints = [ "c7767a13281a56631c72b9b6f69a17746dc02213e7f2b24a8a4a6fe7afd9ee0a" ] + include_fingerprints = [] + + [[modules]] + docstring_result = true + file = "/path/to/project/Main.cry" + fingerprint = "6b36f965ebb1a68cf76d689a966806ec879540aa6576a76c1aaa7705a4af09d5" + foreign_fingerprints = [] + include_fingerprints = [] diff --git a/docs/RefMan/RefMan.rst b/docs/RefMan/RefMan.rst index 02fa7eabf..3d4f3d837 100644 --- a/docs/RefMan/RefMan.rst +++ b/docs/RefMan/RefMan.rst @@ -13,4 +13,5 @@ Cryptol Reference Manual TypeDeclarations Modules FFI + Project diff --git a/src/Cryptol/REPL/Command.hs b/src/Cryptol/REPL/Command.hs index 587fe64d4..913f08016 100644 --- a/src/Cryptol/REPL/Command.hs +++ b/src/Cryptol/REPL/Command.hs @@ -2264,10 +2264,13 @@ loadProjectREPL refresh cfg = pure (fpAcc, False) -- report failure Proj.Scanned Proj.Unchanged _ ((m,_):_) -> do let name = P.thing (P.mName m) - rPrint ("Skipping unmodified module: " <> pp name) let prevResult = join (Map.lookup (Proj.CacheInFile path) docstringResults) + case prevResult of + Just True -> rPrint ("Skipping unmodified module (tests passed): " <> pp name) + Just False -> rPrint ("Skipping unmodified module (tests failed): " <> pp name) + Nothing -> rPrint ("Skipping unmodified module: " <> pp name) let fpAcc' = Map.adjust (\e -> e{ Proj.cacheDocstringResult = prevResult }) (Proj.CacheInFile path) fpAcc - pure (fpAcc', success) -- preserve success + pure (fpAcc', success && prevResult == Just True) -- preserve success Proj.Scanned Proj.Changed _ ((m,_):_) -> do let name = P.thing (P.mName m) rPrint ("Checking docstrings on changed module: " <> pp name) From a49bcf5d52e2b2a09defd0e4357b645617a67502 Mon Sep 17 00:00:00 2001 From: Eric Mertens Date: Fri, 20 Dec 2024 11:31:50 -0800 Subject: [PATCH 35/35] changelog entry --- CHANGES.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 11ffd01cd..1805b5143 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -24,6 +24,10 @@ * The REPL properly supports tab completion for the `:t` and `:check` commands. ([#1780](https://github.com/GaloisInc/cryptol/issues/1780)) +* Add support for incrementally loading projects via cryptol's `--project` + flag as documented in the reference manual. + ([#1641](https://github.com/GaloisInc/cryptol/issues/1641)) + # 3.2.0 -- 2024-08-20 ## Language changes