From e9cd92f0614a18f96db9e7afc818eb749cc8cf88 Mon Sep 17 00:00:00 2001 From: Sofia Faro Date: Tue, 29 Sep 2020 14:14:59 +0100 Subject: [PATCH] Deprecate the "daml 1.2" version header. (#7513) * changelog_begin - [DAML] The "daml 1.2" version header is now deprecated. changelog_end * fix some line numbers * fix some more locations --- compatibility/bazel_tools/daml_ledger/Main.hs | 3 +- .../damlc/daml-doctest/src/DA/Daml/DocTest.hs | 2 - .../test/Development/IDE/Core/API/Testing.hs | 6 +- .../src/DA/Daml/Preprocessor.hs | 12 +- .../tests/daml-test-files/DamlHasVersion.daml | 1 + .../damlc/tests/src/DA/Test/DamlDocTest.hs | 4 +- .../src/DA/Test/DamlDocTestIntegration.hs | 6 +- .../tests/src/DA/Test/GenerateModuleTree.hs | 2 +- .../tests/src/DA/Test/IncrementalBuilds.hs | 33 +- compiler/damlc/tests/src/DA/Test/Packaging.hs | 37 +- .../damlc/tests/src/DA/Test/ShakeIdeClient.hs | 452 ++++++++---------- compiler/damlc/tests/src/DamlcTest.hs | 24 +- .../damlc/tests/src/daml-ghc-deterministic.sh | 1 - compiler/lsp-tests/src/Main.hs | 186 +++---- .../test/DA/Daml/Helper/Test/Deployment.hs | 3 +- .../src/DA/Daml/Assistant/IntegrationTests.hs | 15 +- daml-lf/interpreter/perf/daml/Examples.daml | 2 - .../contract-key-through-exercises/Test.daml | 3 +- docs/source/daml/reference/file-structure.rst | 1 - docs/source/tools/extractor.rst | 32 +- extractor/BUILD.bazel | 4 +- .../src/main/daml/performance/PingPong.daml | 1 - 22 files changed, 351 insertions(+), 479 deletions(-) diff --git a/compatibility/bazel_tools/daml_ledger/Main.hs b/compatibility/bazel_tools/daml_ledger/Main.hs index 34b50161cab..9d5deaad5eb 100644 --- a/compatibility/bazel_tools/daml_ledger/Main.hs +++ b/compatibility/bazel_tools/daml_ledger/Main.hs @@ -284,8 +284,7 @@ writeMinimalProject (SdkVersion sdkVersion) = do , " - daml-stdlib" ] writeFileUTF8 "Main.daml" $ unlines - [ "daml 1.2" - , "module Main where" + [ "module Main where" , "template T with p : Party where signatory p" ] diff --git a/compiler/damlc/daml-doctest/src/DA/Daml/DocTest.hs b/compiler/damlc/daml-doctest/src/DA/Daml/DocTest.hs index 76fd7071fa7..3ded96bb66a 100644 --- a/compiler/damlc/daml-doctest/src/DA/Daml/DocTest.hs +++ b/compiler/damlc/daml-doctest/src/DA/Daml/DocTest.hs @@ -139,7 +139,6 @@ renderDocTestModule DocTestModule{..} = rendered testsWithIds = zip [DocTestId 0..] dtModuleContent rendered = T.unlines $ [ "{-# OPTIONS_GHC -Wno-unused-imports #-}" - , "daml 1.2" , "module " <> docTestModuleName dtModuleName <> " where" , "" , "import " <> dtModuleName @@ -170,4 +169,3 @@ data GeneratedModule = GeneratedModule } deriving (Show, Generic) instance NFData GeneratedModule - diff --git a/compiler/damlc/daml-ide-core/test/Development/IDE/Core/API/Testing.hs b/compiler/damlc/daml-ide-core/test/Development/IDE/Core/API/Testing.hs index d3c4499b348..a30a32e388e 100644 --- a/compiler/damlc/daml-ide-core/test/Development/IDE/Core/API/Testing.hs +++ b/compiler/damlc/daml-ide-core/test/Development/IDE/Core/API/Testing.hs @@ -216,8 +216,7 @@ makeModule :: String -> [T.Text] -> ShakeTest D.NormalizedFilePath makeModule modName body = do let modPath = moduleNameToFilePath modName makeFile modPath . T.unlines $ - [ "daml 1.2" - , "module " <> T.pack modName <> " where" + [ "module " <> T.pack modName <> " where" ] ++ body -- | Set files of interest. @@ -534,8 +533,7 @@ expectedGraph damlFilePath expectedGraph = do example :: ShakeTest () example = do fooPath <- makeFile "src/Foo.daml" $ T.unlines - [ "daml 1.2" - , "module Foo where" + [ "module Foo where" , "data Foo = Foo" , " with" , " bar : Party" diff --git a/compiler/damlc/daml-preprocessor/src/DA/Daml/Preprocessor.hs b/compiler/damlc/daml-preprocessor/src/DA/Daml/Preprocessor.hs index 833766f8f0a..a2a73975a04 100644 --- a/compiler/damlc/daml-preprocessor/src/DA/Daml/Preprocessor.hs +++ b/compiler/damlc/daml-preprocessor/src/DA/Daml/Preprocessor.hs @@ -63,7 +63,7 @@ damlPreprocessor :: Maybe GHC.UnitId -> GHC.ParsedSource -> IdePreprocessedSourc damlPreprocessor mbUnitId x | maybe False (isInternal ||^ (`elem` mayImportInternal)) name = noPreprocessor x | otherwise = IdePreprocessedSource - { preprocWarnings = checkVariantUnitConstructors x + { preprocWarnings = checkDamlHeader x ++ checkVariantUnitConstructors x , preprocErrors = checkImports x ++ checkDataTypes x ++ checkModuleDefinition x ++ checkRecordConstructor x ++ checkModuleName x , preprocSource = recordDotPreprocessor $ importDamlPreprocessor $ genericsPreprocessor mbUnitId $ enumTypePreprocessor "GHC.Types" x } @@ -120,6 +120,16 @@ checkImports x = [ (ss, "Import of internal module " ++ GHC.moduleNameString m ++ " is not allowed.") | GHC.L ss GHC.ImportDecl{ideclName=GHC.L _ m} <- GHC.hsmodImports $ GHC.unLoc x, isInternal m] +-- | Emit a warning if the "daml 1.2" version header is present. +checkDamlHeader :: GHC.ParsedSource -> [(GHC.SrcSpan, String)] +checkDamlHeader (GHC.L _ m) + | Just (GHC.L ss doc) <- GHC.hsmodHaddockModHeader m + , "HAS_DAML_VERSION_HEADER" `isPrefixOf` GHC.unpackHDS doc + = [(ss, "The \"daml 1.2\" version header is deprecated, please remove it.")] + + | otherwise + = [] + -- | Emit a warning if a variant constructor has a single argument of unit type '()'. -- See issue #7207. checkVariantUnitConstructors :: GHC.ParsedSource -> [(GHC.SrcSpan, String)] diff --git a/compiler/damlc/tests/daml-test-files/DamlHasVersion.daml b/compiler/damlc/tests/daml-test-files/DamlHasVersion.daml index 1e486b1055e..e76e33de242 100644 --- a/compiler/damlc/tests/daml-test-files/DamlHasVersion.daml +++ b/compiler/damlc/tests/daml-test-files/DamlHasVersion.daml @@ -1,4 +1,5 @@ daml 1.2 +-- @WARN The "daml 1.2" version header is deprecated, please remove it. -- | Testing the daml version header. module DamlHasVersion(T, main) where diff --git a/compiler/damlc/tests/src/DA/Test/DamlDocTest.hs b/compiler/damlc/tests/src/DA/Test/DamlDocTest.hs index 1507d5d3a60..afc349a8947 100644 --- a/compiler/damlc/tests/src/DA/Test/DamlDocTest.hs +++ b/compiler/damlc/tests/src/DA/Test/DamlDocTest.hs @@ -86,14 +86,12 @@ generateTests = testGroup "generate doctest module" testModuleHeader :: [T.Text] testModuleHeader = - [ "daml 1.2" - , "module Test where" + [ "module Test where" ] doctestHeader :: [T.Text] doctestHeader = [ "{-# OPTIONS_GHC -Wno-unused-imports #-}" - , "daml 1.2" , "module Test_doctest where" , "" , "import Test" diff --git a/compiler/damlc/tests/src/DA/Test/DamlDocTestIntegration.hs b/compiler/damlc/tests/src/DA/Test/DamlDocTestIntegration.hs index e865c998497..c70db071c49 100644 --- a/compiler/damlc/tests/src/DA/Test/DamlDocTestIntegration.hs +++ b/compiler/damlc/tests/src/DA/Test/DamlDocTestIntegration.hs @@ -23,8 +23,7 @@ tests damlcPath = testGroup "doctest integration tests" withTempDir $ \tmpDir -> do let f = tmpDir "Main.daml" writeFileUTF8 f $ unlines - [ "daml 1.2" - , "module Main where" + [ "module Main where" , "-- | add" , "-- >>> add 1 1" , "-- 2" @@ -43,8 +42,7 @@ tests damlcPath = testGroup "doctest integration tests" withTempDir $ \tmpDir -> do let f = tmpDir "Main.daml" writeFileUTF8 f $ unlines - [ "daml 1.2" - , "module Main where" + [ "module Main where" , "-- | add" , "-- >>> add 1 1" , "-- 2" diff --git a/compiler/damlc/tests/src/DA/Test/GenerateModuleTree.hs b/compiler/damlc/tests/src/DA/Test/GenerateModuleTree.hs index b051ece2dc2..74cf10b0195 100644 --- a/compiler/damlc/tests/src/DA/Test/GenerateModuleTree.hs +++ b/compiler/damlc/tests/src/DA/Test/GenerateModuleTree.hs @@ -32,7 +32,7 @@ mkModule n = T.unlines ] mkHeader :: Int -> T.Text -mkHeader n = T.pack $ "daml 1.2\nmodule " <> stdModName n <> "\n where" +mkHeader n = T.pack $ "module " <> stdModName n <> "\n where" mkImport :: Int -> T.Text mkImport k = T.pack $ "import qualified " <> stdModName k diff --git a/compiler/damlc/tests/src/DA/Test/IncrementalBuilds.hs b/compiler/damlc/tests/src/DA/Test/IncrementalBuilds.hs index c5c9c557e5f..df1d4e6227c 100644 --- a/compiler/damlc/tests/src/DA/Test/IncrementalBuilds.hs +++ b/compiler/damlc/tests/src/DA/Test/IncrementalBuilds.hs @@ -25,8 +25,7 @@ tests :: FilePath -> FilePath -> TestTree tests damlc repl = testGroup "Incremental builds" [ test "No changes" [ ("daml/A.daml", unlines - [ "daml 1.2" - , "module A where" + [ "module A where" ] ) ] @@ -35,15 +34,13 @@ tests damlc repl = testGroup "Incremental builds" (ShouldSucceed True) , test "Modify single file" [ ("daml/A.daml", unlines - [ "daml 1.2" - , "module A where" + [ "module A where" , "test = scenario $ assert True" ] ) ] [ ("daml/A.daml", unlines - [ "daml 1.2" - , "module A where" + [ "module A where" , "test = scenario $ assert False" ] ) @@ -52,22 +49,19 @@ tests damlc repl = testGroup "Incremental builds" (ShouldSucceed False) , test "Modify dependency without ABI change" [ ("daml/A.daml", unlines - [ "daml 1.2" - , "module A where" + [ "module A where" , "import B" , "test = scenario $ b" ] ) , ("daml/B.daml", unlines - [ "daml 1.2" - , "module B where" + [ "module B where" , "b = scenario $ assert True" ] ) ] [ ("daml/B.daml", unlines - [ "daml 1.2" - , "module B where" + [ "module B where" , "b = scenario $ assert False" ] ) @@ -76,23 +70,20 @@ tests damlc repl = testGroup "Incremental builds" (ShouldSucceed False) , test "Modify dependency with ABI change" [ ("daml/A.daml", unlines - [ "daml 1.2" - , "module A where" + [ "module A where" , "import B" , "test = scenario $ do _ <- b; pure ()" ] ) , ("daml/B.daml", unlines - [ "daml 1.2" - , "module B where" + [ "module B where" , "b : Scenario Bool" , "b = pure True" ] ) ] [ ("daml/B.daml", unlines - [ "daml 1.2" - , "module B where" + [ "module B where" , "b : Scenario ()" , "b = assert False" ] @@ -104,7 +95,7 @@ tests damlc repl = testGroup "Incremental builds" -- This test checks that we setup dependent modules in the right order. Note that just having imports is not sufficient -- to trigger this. The modules actually need to use identifiers from the other modules. [ ("daml/A.daml", unlines - [ "daml 1.2 module A where" + [ "module A where" , "import B" , "test = scenario $ do" , " p <- getParty \"Alice\"" @@ -113,7 +104,7 @@ tests damlc repl = testGroup "Incremental builds" ] ) , ("daml/B.daml", unlines - [ "daml 1.2 module B (module C, Y(..)) where" + [ "module B (module C, Y(..)) where" , "import C" , "template Y" , " with p : Party; cid : ContractId X" @@ -121,7 +112,7 @@ tests damlc repl = testGroup "Incremental builds" ] ) , ("daml/C.daml", unlines - [ "daml 1.2 module C where" + [ "module C where" , "template X" , " with p : Party" , " where signatory p" diff --git a/compiler/damlc/tests/src/DA/Test/Packaging.hs b/compiler/damlc/tests/src/DA/Test/Packaging.hs index 6f870c05134..8c62c71f004 100644 --- a/compiler/damlc/tests/src/DA/Test/Packaging.hs +++ b/compiler/damlc/tests/src/DA/Test/Packaging.hs @@ -416,7 +416,7 @@ tests tools@Tools{damlc} = testGroup "Packaging" $ , "dependencies: [daml-prim, daml-stdlib]" ] writeFileUTF8 (projDir "A.daml") $ unlines - [ "daml 1.2 module A where" + [ "module A where" ] withCurrentDirectory projDir $ callProcessSilent damlc ["build", "-o", "foobar.dar", "--target=1.dev"] Right Dalfs{..} <- readDalfs . Zip.toArchive <$> BSL.readFile (projDir "foobar.dar") @@ -627,7 +627,7 @@ tests tools@Tools{damlc} = testGroup "Packaging" $ , "build-options: [--target=1.8]" ] writeFileUTF8 (tmpDir "a" "A.daml") $ unlines - [ "daml 1.2 module A where" + [ "module A where" ] withCurrentDirectory (tmpDir "a") $ callProcessSilent damlc ["build", "-o", tmpDir "a" "a.dar"] @@ -646,7 +646,7 @@ tests tools@Tools{damlc} = testGroup "Packaging" $ , "build-options: [--target=1.7]" ] writeFileUTF8 (tmpDir "b" "B.daml") $ unlines - [ "daml 1.2 module B where" + [ "module B where" , "import A ()" ] buildProjectError (tmpDir "b") "" "Targeted LF version 1.7 but dependencies have newer LF versions" @@ -663,7 +663,7 @@ tests tools@Tools{damlc} = testGroup "Packaging" $ , "build-options: [--target=1.8]" ] writeFileUTF8 (tmpDir "a" "A.daml") $ unlines - [ "daml 1.2 module A where" + [ "module A where" ] withCurrentDirectory (tmpDir "a") $ callProcessSilent damlc ["build", "-o", tmpDir "a" "a.dar"] @@ -681,7 +681,7 @@ tests tools@Tools{damlc} = testGroup "Packaging" $ , "build-options: [--target=1.7]" ] writeFileUTF8 (tmpDir "b" "B.daml") $ unlines - [ "daml 1.2 module B where" + [ "module B where" , "import A ()" ] buildProjectError (tmpDir "b") "" "Targeted LF version 1.7 but dependencies have newer LF versions" @@ -854,7 +854,7 @@ lfVersionTests damlc = testGroup "LF version dependencies" , "dependencies: [daml-prim, daml-stdlib]" ] writeFileUTF8 (projDir "A.daml") $ unlines - [ "daml 1.2 module A where"] + [ "module A where"] withCurrentDirectory projDir $ callProcessSilent damlc ["build", "-o", projDir "proj.dar", "--target", LF.renderVersion version] archive <- Zip.toArchive <$> BSL.readFile (projDir "proj.dar") DalfManifest {mainDalfPath, dalfPaths} <- either fail pure $ readDalfManifest archive @@ -891,8 +891,7 @@ dataDependencyTests Tools{damlc,repl,validate,davlDar,oldProjDar} = testGroup "D step "Build proja" createDirectoryIfMissing True (proja "src") writeFileUTF8 (proja "src" "A.daml") $ unlines - [" daml 1.2" - , "module A where" + [ "module A where" , "import DA.Text" , "data A = A Int deriving Show" -- This ensures that we have a reference to daml-stdlib and therefore daml-prim. @@ -1022,7 +1021,7 @@ dataDependencyTests Tools{damlc,repl,validate,davlDar,oldProjDar} = testGroup "D , "dependencies: [daml-prim, daml-stdlib]" ] writeFileUTF8 (tmpDir "lib" "Lib.daml") $ unlines - [ "daml 1.2 module Lib where" + [ "module Lib where" , "inc : Int -> Int" , "inc = (+ 1)" ] @@ -1042,7 +1041,7 @@ dataDependencyTests Tools{damlc,repl,validate,davlDar,oldProjDar} = testGroup "D , " - " <> show (tmpDir "lib" "lib.dar") ] writeFileUTF8 (tmpDir "a" "A.daml") $ unlines - [ "daml 1.2 module A where" + [ "module A where" , "import Lib" , "two : Int" , "two = inc 1" @@ -1065,7 +1064,7 @@ dataDependencyTests Tools{damlc,repl,validate,davlDar,oldProjDar} = testGroup "D , "data-dependencies: [" <> show (tmpDir "a" "a.dar") <> "]" ] writeFileUTF8 (tmpDir "b" "B.daml") $ unlines - [ "daml 1.2 module B where" + [ "module B where" , "import Lib" , "import A" , "three : Int" @@ -1215,7 +1214,7 @@ dataDependencyTests Tools{damlc,repl,validate,davlDar,oldProjDar} = testGroup "D , "dependencies: [daml-prim, daml-stdlib]" ] writeFileUTF8 (projDir "Lib.daml") $ unlines - [ "daml 1.2 module Lib where" + [ "module Lib where" , "data X" <> version <> " = X" ] withCurrentDirectory projDir $ callProcessSilent damlc ["build", "-o", projDir "lib.dar"] @@ -1233,7 +1232,7 @@ dataDependencyTests Tools{damlc,repl,validate,davlDar,oldProjDar} = testGroup "D , "- " <> show (tmpDir "lib-1" "lib.dar") ] writeFileUTF8 (projDir "A.daml") $ unlines - [ "daml 1.2 module A where" + [ "module A where" , "import Lib" , "data A = A X1" ] @@ -1253,7 +1252,7 @@ dataDependencyTests Tools{damlc,repl,validate,davlDar,oldProjDar} = testGroup "D , "- " <> show (tmpDir "a" "a.dar") ] writeFileUTF8 (projDir "B.daml") $ unlines - [ "daml 1.2 module B where" + [ "module B where" , "import Lib" , "import A" , "data B1 = B1 A" @@ -1278,7 +1277,7 @@ dataDependencyTests Tools{damlc,repl,validate,davlDar,oldProjDar} = testGroup "D , "- " <> show (tmpDir "lib-2" "lib.dar") ] writeFileUTF8 (projDir "C.daml") $ unlines - [ "daml 1.2 module C where" + [ "module C where" , "import B" , "import Lib" , "f : B2 -> X2" @@ -1560,7 +1559,7 @@ dataDependencyTests Tools{damlc,repl,validate,davlDar,oldProjDar} = testGroup "D , "build-options: [--target=1.dev]" ] writeFileUTF8 (tmpDir "type" "Proxy.daml") $ unlines - [ "daml 1.2 module Proxy where" + [ "module Proxy where" , "data Proxy a = Proxy {}" ] withCurrentDirectory (tmpDir "type") $ callProcessSilent damlc ["build", "-o", "type.dar"] @@ -1577,7 +1576,7 @@ dataDependencyTests Tools{damlc,repl,validate,davlDar,oldProjDar} = testGroup "D , "build-options: [ \"--target=1.dev\" ]" ] writeFileUTF8 (tmpDir "dependency" "Dependency.daml") $ unlines - [ "daml 1.2 module Dependency where" + [ "module Dependency where" , "import Proxy" , "instance Functor Proxy where" , " fmap _ Proxy = Proxy" @@ -1596,7 +1595,7 @@ dataDependencyTests Tools{damlc,repl,validate,davlDar,oldProjDar} = testGroup "D , "build-options: [ \"--target=1.dev\" ]" ] writeFileUTF8 (tmpDir "data-dependency" "DataDependency.daml") $ unlines - [ "daml 1.2 module DataDependency where" + [ "module DataDependency where" , "import Proxy" , "instance Functor Proxy where" , " fmap _ Proxy = Proxy" @@ -1618,7 +1617,7 @@ dataDependencyTests Tools{damlc,repl,validate,davlDar,oldProjDar} = testGroup "D , "build-options: [--target=1.dev]" ] writeFileUTF8 (tmpDir "top" "Top.daml") $ unlines - [ "daml 1.2 module Top where" + [ "module Top where" , "import DataDependency" , "import Proxy" -- Test that we can use the Applicaive instance of Proxy from the data-dependency diff --git a/compiler/damlc/tests/src/DA/Test/ShakeIdeClient.hs b/compiler/damlc/tests/src/DA/Test/ShakeIdeClient.hs index 962fee51ebd..ae69bcd1f6e 100644 --- a/compiler/damlc/tests/src/DA/Test/ShakeIdeClient.hs +++ b/compiler/damlc/tests/src/DA/Test/ShakeIdeClient.hs @@ -72,53 +72,47 @@ basicTests mbScenarioService = Tasty.testGroup "Basic tests" , testCase' "Set files of interest and expect parse error" $ do foo <- makeFile "Foo.daml" $ T.unlines - [ "daml 1.2" - , "module Foo where" + [ "module Foo where" , "this is bad syntax" ] setFilesOfInterest [foo] - expectOneError (foo,2,0) "Parse error" + expectOneError (foo,1,0) "Parse error" , testCase' "Set files of interest to clear parse error" $ do foo <- makeFile "Foo.daml" $ T.unlines - [ "daml 1.2" - , "module Foo where" + [ "module Foo where" , "this is bad syntax" ] setFilesOfInterest [foo] - expectOneError (foo,2,0) "Parse error" + expectOneError (foo,1,0) "Parse error" setFilesOfInterest [] expectNoErrors , testCase' "Expect parse errors in two independent modules" $ do foo <- makeFile "src/Foo.daml" $ T.unlines - [ "daml 1.2" - , "module Foo where" + [ "module Foo where" , "foo : Int" , "foo = 10" , "this is bad syntax" ] bar <- makeFile "src/Bar.daml" $ T.unlines - [ "daml 1.2" - , "module Bar where" + [ "module Bar where" , "bar : Int" , "bar = 10" , "this is bad syntax" ] setFilesOfInterest [foo, bar] - expectOnlyErrors [((foo,4,0), "Parse error"), ((bar,4,0), "Parse error")] + expectOnlyErrors [((foo,3,0), "Parse error"), ((bar,3,0), "Parse error")] , testCase' "Simple module import" $ do foo <- makeFile "src/Foo.daml" $ T.unlines - [ "daml 1.2" - , "module Foo where" + [ "module Foo where" , "import Bar" , "foo : Int" , "foo = bar" ] bar <- makeFile "src/Bar.daml" $ T.unlines - [ "daml 1.2" - , "module Bar where" + [ "module Bar where" , "bar : Int" , "bar = 10" ] @@ -127,67 +121,59 @@ basicTests mbScenarioService = Tasty.testGroup "Basic tests" , testCase' "Cyclic module import" $ do f <- makeFile "src/Cycle.daml" $ T.unlines - [ "daml 1.2" - , "module Cycle where" + [ "module Cycle where" , "import Cycle" ] setFilesOfInterest [f] - expectOneError (f,2,7) "Cyclic module dependency between Cycle" + expectOneError (f,1,7) "Cyclic module dependency between Cycle" , testCase' "Modify file to introduce error" $ do foo <- makeFile "Foo.daml" $ T.unlines - [ "daml 1.2" - , "module Foo where" + [ "module Foo where" , "foo : Int" , "foo = 10" ] setFilesOfInterest [foo] expectNoErrors _ <- makeFile "Foo.daml" $ T.unlines - [ "daml 1.2" - , "module Foo where" + [ "module Foo where" , "foo : Int" , "foo = 10.5" ] - expectOneError (foo,3,6) "Couldn't match expected type" + expectOneError (foo,2,6) "Couldn't match expected type" , testCase' "Set buffer modified to introduce error then clear it" $ do foo <- makeFile "Foo.daml" $ T.unlines - [ "daml 1.2" - , "module Foo where" + [ "module Foo where" , "foo : Int" , "foo = 10" ] setFilesOfInterest [foo] expectNoErrors setBufferModified foo $ T.unlines - [ "daml 1.2" - , "module Foo where" + [ "module Foo where" , "foo : Int" , "foo = 10.5" ] - expectOneError (foo,3,6) "Couldn't match expected type" + expectOneError (foo,2,6) "Couldn't match expected type" setBufferNotModified foo expectNoErrors , testCase' "Open two modules with the same name but different directory" $ do f1 <- makeFile "src1/Main.daml" $ T.unlines - [ "daml 1.2" - , "module Main where" + [ "module Main where" , "i : Int" , "i = 1" ] f2 <- makeFile "src2/Main.daml" $ T.unlines - [ "daml 1.2" - , "module Main where" + [ "module Main where" ] setFilesOfInterest [f1, f2] expectNoErrors , testCase' "Run scenarios in two modules with the same name but different directory" $ do let header = - [ "daml 1.2" - , "module Main where" ] + [ "module Main where" ] goodScenario = [ "v = scenario do" , " pure ()" ] @@ -206,40 +192,40 @@ basicTests mbScenarioService = Tasty.testGroup "Basic tests" expectVirtualResource vr1 "Return value: {}" expectVirtualResource vr2 "Return value: {}" setBufferModified f2 badFileContent - expectOneError (f2,2,0) "Aborted: Assertion failed" + expectOneError (f2,1,0) "Aborted: Assertion failed" expectVirtualResource vr1 "Return value: {}" expectVirtualResource vr2 "Aborted: Assertion failed" , testCase' "Deleting a file you import DEL-7189" $ do - a <- makeFile "A.daml" "daml 1.2 module A where; import B" + a <- makeFile "A.daml" "module A where; import B" setFilesOfInterest [a] - expectOneError (a,0,32) "Could not find module" - b <- makeFile "B.daml" "daml 1.2 module B where" - expectWarning (a,0,25) "The import of ‘B’ is redundant" + expectOneError (a,0,23) "Could not find module" + b <- makeFile "B.daml" "module B where" + expectWarning (a,0,16) "The import of ‘B’ is redundant" expectNoErrors liftIO $ removeFile (fromNormalizedFilePath b) expectOnlyDiagnostics - [(DsError, (a,0,32), "Could not find module") + [(DsError, (a,0,23), "Could not find module") -- the warning says around because of DEL-7199 - ,(DsWarning, (a,0,25), "The import of ‘B’ is redundant")] + ,(DsWarning, (a,0,16), "The import of ‘B’ is redundant")] , testCase' "Early errors kill later warnings" $ do - a <- makeFile "A.daml" "daml 1.2 module A where; import B" - _ <- makeFile "B.daml" "daml 1.2 module B where" + a <- makeFile "A.daml" "module A where; import B" + _ <- makeFile "B.daml" "module B where" setFilesOfInterest [a] - expectWarning (a,0,25) "The import of ‘B’ is redundant" + expectWarning (a,0,16) "The import of ‘B’ is redundant" setBufferModified a "???" expectOneError (a,0,0) "parse error on input" , testCase' "Loading two modules with the same name DEL-7175" $ do - a <- makeFile "foo/Test.daml" "daml 1.2 module Test where" - b <- makeFile "bar/Test.daml" "daml 1.2 module Test where" + a <- makeFile "foo/Test.daml" "module Test where" + b <- makeFile "bar/Test.daml" "module Test where" setFilesOfInterest [a, b] expectNoErrors , testCase' "Run two scenarios with the same name DEL-7175" $ do - a <- makeFile "foo/Test.daml" "daml 1.2 module Test where main = scenario $ return \"foo\"" - b <- makeFile "bar/Test.daml" "daml 1.2 module Test where main = scenario $ return \"bar\"" + a <- makeFile "foo/Test.daml" "module Test where main = scenario $ return \"foo\"" + b <- makeFile "bar/Test.daml" "module Test where main = scenario $ return \"bar\"" setFilesOfInterest [a, b] expectNoErrors let va = VRScenario a "main" @@ -271,19 +257,19 @@ basicTests mbScenarioService = Tasty.testGroup "Basic tests" , testCaseFails' "Modules must match their filename DEL-7175" $ do - a <- makeFile "Foo/Test.daml" "daml 1.2 module Test where" + a <- makeFile "Foo/Test.daml" "module Test where" setFilesOfInterest [a] expectNoErrors - setBufferModified a "daml 1.2 module Foo.Test where" + setBufferModified a "module Foo.Test where" expectNoErrors - setBufferModified a "daml 1.2 module Bob where" + setBufferModified a "module Bob where" expectOneError (a,0,0) "HERE1" - setBufferModified a "daml 1.2 module TEST where" + setBufferModified a "module TEST where" expectOneError (a,0,0) "HERE2" , testCaseFails' "Case insensitive files and module names DEL-7175" $ do - a <- makeFile "Test.daml" "daml 1.2 module Test where; import CaSe; import Case" - _ <- makeFile "CaSe.daml" "daml 1.2 module Case where" + a <- makeFile "Test.daml" "module Test where; import CaSe; import Case" + _ <- makeFile "CaSe.daml" "module Case where" setFilesOfInterest [a] expectNoErrors ] @@ -295,20 +281,18 @@ dlintSmokeTests :: Maybe SS.Handle -> Tasty.TestTree dlintSmokeTests mbScenarioService = Tasty.testGroup "Dlint smoke tests" [ testCase' "Imports can be simplified" $ do foo <- makeFile "Foo.daml" $ T.unlines - [ "daml 1.2" - , "module Foo where" + [ "module Foo where" , "import DA.Optional" , "import DA.Optional(fromSome)" ] setFilesOfInterest [foo] expectNoErrors - expectDiagnostic DsInfo (foo, 2, 0) "Warning: Use fewer imports" + expectDiagnostic DsInfo (foo, 1, 0) "Warning: Use fewer imports" -- This hint is now disabled. See PR -- https://github.com/digital-asset/daml/pull/6423 for details. -- , testCase' "Reduce duplication" $ do -- foo <- makeFile "Foo.daml" $ T.unlines - -- [ "daml 1.2" - -- , "module Foo where" + -- [ "module Foo where" -- , "import DA.List" -- , "testSort5 = scenario do" -- , " let l = [ (2, const \"D\"), (1, const \"A\"), (1, const \"B\"), (3, const \"E\"), (1, const \"C\") ]" @@ -327,11 +311,10 @@ dlintSmokeTests mbScenarioService = Tasty.testGroup "Dlint smoke tests" -- ] -- setFilesOfInterest [foo] -- expectNoErrors - -- expectDiagnostic DsInfo (foo, 7, 4) "Suggestion: Reduce duplication" + -- expectDiagnostic DsInfo (foo, 6, 4) "Suggestion: Reduce duplication" , testCase' "Use language pragmas" $ do foo <- makeFile "Foo.daml" $ T.unlines [ "{-# OPTIONS_GHC -XDataKinds #-}" - , "daml 1.2" , "module Foo where" ] setFilesOfInterest [foo] @@ -341,7 +324,6 @@ dlintSmokeTests mbScenarioService = Tasty.testGroup "Dlint smoke tests" foo <- makeFile "Foo.daml" $ T.unlines [ "{-# LANGUAGE ScopedTypeVariables, DataKinds #-}" , "{-# LANGUAGE ScopedTypeVariables #-}" - , "daml 1.2" , "module Foo where" ] setFilesOfInterest [foo] @@ -349,221 +331,197 @@ dlintSmokeTests mbScenarioService = Tasty.testGroup "Dlint smoke tests" expectDiagnostic DsInfo (foo, 0, 0) "Warning: Use fewer LANGUAGE pragmas" , testCase' "Use map" $ do foo <- makeFile "Foo.daml" $ T.unlines - [ "daml 1.2" - , "module Foo where" + [ "module Foo where" , "g : [Int] -> [Int]" , "g (x :: xs) = x + 1 :: g xs" , "g [] = []"] setFilesOfInterest [foo] expectNoErrors - expectDiagnostic DsInfo (foo, 3, 0) "Warning: Use map" + expectDiagnostic DsInfo (foo, 2, 0) "Warning: Use map" , testCase' "Use foldr" $ do foo <- makeFile "Foo.daml" $ T.unlines - [ "daml 1.2" - , "module Foo where" + [ "module Foo where" , "f : [Int] -> Int" , "f (x :: xs) = negate x + f xs" , "f [] = 0"] setFilesOfInterest [foo] expectNoErrors - expectDiagnostic DsInfo (foo, 3, 0) "Suggestion: Use foldr" + expectDiagnostic DsInfo (foo, 2, 0) "Suggestion: Use foldr" , testCase' "Short-circuited list comprehension" $ do foo <- makeFile "Foo.daml" $ T.unlines - [ "daml 1.2" - , "module Foo where" + [ "module Foo where" , "foo = [x | False, x <- [1..10]]" ] setFilesOfInterest [foo] expectNoErrors - expectDiagnostic DsInfo (foo, 2, 6) "Suggestion: Short-circuited list comprehension" + expectDiagnostic DsInfo (foo, 1, 6) "Suggestion: Short-circuited list comprehension" , testCase' "Redundant true guards" $ do foo <- makeFile "Foo.daml" $ T.unlines - [ "daml 1.2" - , "module Foo where" + [ "module Foo where" , "foo = [x | True, x <- [1..10]]" ] setFilesOfInterest [foo] expectNoErrors - expectDiagnostic DsInfo (foo, 2, 6) "Suggestion: Redundant True guards" + expectDiagnostic DsInfo (foo, 1, 6) "Suggestion: Redundant True guards" , testCase' "Move guards forward" $ do foo <- makeFile "Foo.daml" $ T.unlines - [ "daml 1.2" - , "module Foo where" + [ "module Foo where" , "foo feature = [x | x <- [1..10], feature]" ] setFilesOfInterest [foo] expectNoErrors - expectDiagnostic DsInfo (foo, 2, 14) "Suggestion: Move guards forward" + expectDiagnostic DsInfo (foo, 1, 14) "Suggestion: Move guards forward" , testCase' "Move map inside list comprehension" $ do foo <- makeFile "Foo.daml" $ T.unlines - [ "daml 1.2" - , "module Foo where" + [ "module Foo where" , "foo = map f [x | x <- [1..10]] where f x = x * x" ] setFilesOfInterest [foo] expectNoErrors - expectDiagnostic DsInfo (foo, 2, 6) "Suggestion: Move map inside list comprehension" + expectDiagnostic DsInfo (foo, 1, 6) "Suggestion: Move map inside list comprehension" , testCase' "Use list literal" $ do foo <- makeFile "Foo.daml" $ T.unlines - [ "daml 1.2" - , "module Foo where" + [ "module Foo where" , "foo = 1 :: 2 :: []" ] setFilesOfInterest [foo] expectNoErrors - expectDiagnostic DsInfo (foo, 2, 6) "Suggestion: Use list literal" + expectDiagnostic DsInfo (foo, 1, 6) "Suggestion: Use list literal" , testCase' "Use list literal pattern" $ do foo <- makeFile "Foo.daml" $ T.unlines - [ "daml 1.2" - , "module Foo where" + [ "module Foo where" , "foo (1 :: 2 :: []) = 1" ] setFilesOfInterest [foo] expectNoErrors - expectDiagnostic DsInfo (foo, 2, 4) "Suggestion: Use list literal pattern" + expectDiagnostic DsInfo (foo, 1, 4) "Suggestion: Use list literal pattern" , testCase' "Use '::'" $ do foo <- makeFile "Foo.daml" $ T.unlines - [ "daml 1.2" - , "module Foo where" + [ "module Foo where" , "foo x xs = [x] ++ xs" ] setFilesOfInterest [foo] expectNoErrors - expectDiagnostic DsInfo (foo, 2, 11) "Suggestion: Use ::" + expectDiagnostic DsInfo (foo, 1, 11) "Suggestion: Use ::" , testCase' "Use guards" $ do foo <- makeFile "Foo.daml" $ T.unlines - [ "daml 1.2" - , "module Foo where" + [ "module Foo where" , "truth i = if i == 1 then Some True else if i == 2 then Some False else None" ] setFilesOfInterest [foo] expectNoErrors - expectDiagnostic DsInfo (foo, 2, 0) "Suggestion: Use guards" + expectDiagnostic DsInfo (foo, 1, 0) "Suggestion: Use guards" , testCase' "Redundant guard" $ do foo <- makeFile "Foo.daml" $ T.unlines - [ "daml 1.2" - , "module Foo where" + [ "module Foo where" , "foo i | otherwise = True" ] setFilesOfInterest [foo] expectNoErrors - expectDiagnostic DsInfo (foo, 2, 0) "Suggestion: Redundant guard" + expectDiagnostic DsInfo (foo, 1, 0) "Suggestion: Redundant guard" , testCase' "Redundant where" $ do foo <- makeFile "Foo.daml" $ T.unlines - [ "daml 1.2" - , "module Foo where" + [ "module Foo where" , "foo i = i where" ] setFilesOfInterest [foo] expectNoErrors - expectDiagnostic DsInfo (foo, 2, 0) "Suggestion: Redundant where" + expectDiagnostic DsInfo (foo, 1, 0) "Suggestion: Redundant where" , testCase' "Use otherwise" $ do foo <- makeFile "Foo.daml" $ T.unlines - [ "daml 1.2" - , "module Foo where" + [ "module Foo where" , "foo i | i == 1 = True | True = False" ] setFilesOfInterest [foo] expectNoErrors - expectDiagnostic DsInfo (foo, 2, 0) "Suggestion: Use otherwise" + expectDiagnostic DsInfo (foo, 1, 0) "Suggestion: Use otherwise" , testCase' "Use record patterns" $ do foo <- makeFile "Foo.daml" $ T.unlines - [ "daml 1.2" - , "module Foo where" + [ "module Foo where" , "data Foo = Foo with a : Int, b : Int, c : Int, d : Int" , "foo (Foo _ _ _ _) = True" ] setFilesOfInterest [foo] expectNoErrors - expectDiagnostic DsInfo (foo, 3, 5) "Suggestion: Use record patterns" + expectDiagnostic DsInfo (foo, 2, 5) "Suggestion: Use record patterns" , testCase' "Used otherwise as a pattern" $ do foo <- makeFile "Foo.daml" $ T.unlines - [ "daml 1.2" - , "module Foo where" + [ "module Foo where" , "foo otherwise = 1" ] setFilesOfInterest [foo] expectNoErrors - expectDiagnostic DsInfo (foo, 2, 4) "Warning: Used otherwise as a pattern" + expectDiagnostic DsInfo (foo, 1, 4) "Warning: Used otherwise as a pattern" , testCase' "Redundant bang pattern" $ do foo <- makeFile "Foo.daml" $ T.unlines [ "{-# LANGUAGE BangPatterns #-}" - , "daml 1.2" , "module Foo where" , "foo !True = 1" ] setFilesOfInterest [foo] expectNoErrors - expectDiagnostic DsInfo (foo, 3, 4) "Warning: Redundant bang pattern" + expectDiagnostic DsInfo (foo, 2, 4) "Warning: Redundant bang pattern" , testCase' "Redundant irrefutable pattern" $ do foo <- makeFile "Foo.daml" $ T.unlines - [ "daml 1.2" - , "module Foo where" + [ "module Foo where" , "foo y = let ~x = 1 in y" ] setFilesOfInterest [foo] expectNoErrors - expectDiagnostic DsInfo (foo, 2, 12) "Warning: Redundant irrefutable pattern" + expectDiagnostic DsInfo (foo, 1, 12) "Warning: Redundant irrefutable pattern" , testCase' "Redundant as-pattern" $ do foo <- makeFile "Foo.daml" $ T.unlines - [ "daml 1.2" - , "module Foo where" + [ "module Foo where" , "foo y@_ = True" ] setFilesOfInterest [foo] expectNoErrors - expectDiagnostic DsInfo (foo, 2, 4) "Warning: Redundant as-pattern" + expectDiagnostic DsInfo (foo, 1, 4) "Warning: Redundant as-pattern" , testCase' "Redundant case (1)" $ do foo <- makeFile "Foo.daml" $ T.unlines - [ "daml 1.2" - , "module Foo where" + [ "module Foo where" , "foo i = case i of _ -> i" ] setFilesOfInterest [foo] expectNoErrors - expectDiagnostic DsInfo (foo, 2, 8) "Suggestion: Redundant case" + expectDiagnostic DsInfo (foo, 1, 8) "Suggestion: Redundant case" , testCase' "Redundant case (2)" $ do foo <- makeFile "Foo.daml" $ T.unlines - [ "daml 1.2" - , "module Foo where" + [ "module Foo where" , "foo i = case i of i -> i" ] setFilesOfInterest [foo] expectNoErrors - expectDiagnostic DsInfo (foo, 2, 8) "Suggestion: Redundant case" + expectDiagnostic DsInfo (foo, 1, 8) "Suggestion: Redundant case" , testCase' "Use let" $ do foo <- makeFile "Foo.daml" $ T.unlines - [ "daml 1.2" - , "module Foo where" + [ "module Foo where" , "foo g x = do" , " y <- pure x" , " g y" ] setFilesOfInterest [foo] expectNoErrors - expectDiagnostic DsInfo (foo, 2, 10) "Suggestion: Use let" + expectDiagnostic DsInfo (foo, 1, 10) "Suggestion: Use let" , testCase' "Redundant void" $ do foo <- makeFile "Foo.daml" $ T.unlines - [ "daml 1.2" - , "module Foo where" + [ "module Foo where" , "import DA.Action" , "import DA.Foldable" , "foo g xs = void $ forA_ g xs" ] setFilesOfInterest [foo] expectNoErrors - expectDiagnostic DsInfo (foo, 4, 11) "Warning: Redundant void" + expectDiagnostic DsInfo (foo, 3, 11) "Warning: Redundant void" , testCase' "Use <$>" $ do foo <- makeFile "Foo.daml" $ T.unlines - [ "daml 1.2" - , "module Foo where" + [ "module Foo where" , "foo f g bar = do x <- bar; return (f $ g x)" ] setFilesOfInterest [foo] expectNoErrors - expectDiagnostic DsInfo (foo, 2, 14) "Warning: Use <$>" + expectDiagnostic DsInfo (foo, 1, 14) "Warning: Use <$>" , testCase' "Redundant return" $ do foo <- makeFile "Foo.daml" $ T.unlines - [ "daml 1.2" - , "module Foo where" + [ "module Foo where" , "foo bar = do x <- bar; return x" ] setFilesOfInterest [foo] expectNoErrors - expectDiagnostic DsInfo (foo, 2, 10) "Warning: Redundant return" + expectDiagnostic DsInfo (foo, 1, 10) "Warning: Redundant return" ] where testCase' = testCase mbScenarioService @@ -571,19 +529,19 @@ dlintSmokeTests mbScenarioService = Tasty.testGroup "Dlint smoke tests" minimalRebuildTests :: Maybe SS.Handle -> Tasty.TestTree minimalRebuildTests mbScenarioService = Tasty.testGroup "Minimal rebuild tests" [ testCase' "Minimal rebuild" $ do - a <- makeFile "A.daml" "daml 1.2\nmodule A where\nimport B" - _ <- makeFile "B.daml" "daml 1.2\nmodule B where" + a <- makeFile "A.daml" "module A where\nimport B" + _ <- makeFile "B.daml" "module B where" setFilesOfInterest [a] expectLastRebuilt $ \_ _ -> True -- anything is legal expectLastRebuilt $ \_ _ -> False -- now break the code, should only rebuild the thing that broke - setBufferModified a "daml 1.2\nmodule A where\nimport B\n?" + setBufferModified a "module A where\nimport B\n?" expectLastRebuilt $ \_ file -> file == "A.daml" expectLastRebuilt $ \_ _ -> False -- now fix it - setBufferModified a "daml 1.2\nmodule A where\nimport B\n " + setBufferModified a "module A where\nimport B\n " expectLastRebuilt $ \_ file -> file == "A.daml" expectLastRebuilt $ \_ _ -> False ] @@ -596,8 +554,7 @@ goToDefinitionTests :: Maybe SS.Handle -> Tasty.TestTree goToDefinitionTests mbScenarioService = Tasty.testGroup "Go to definition tests" [ testCase' "Go to definition in same module" $ do foo <- makeFile "Foo.daml" $ T.unlines - [ "daml 1.2" - , "module Foo where" + [ "module Foo where" , "foo : Int" , "foo = bar" , "bar : Int" @@ -605,40 +562,37 @@ goToDefinitionTests mbScenarioService = Tasty.testGroup "Go to definition tests" ] setFilesOfInterest [foo] expectNoErrors - expectGoToDefinition (foo,2,[-1]) Missing -- (out of range) - -- expectGoToDefinition (foo,2,[0..2]) (At (foo,3,0)) -- "foo" [see failing test "Go to definition takes type sig to definition"] - expectGoToDefinition (foo,2,[2..4]) Missing -- " : " + expectGoToDefinition (foo,1,[-1]) Missing -- (out of range) + -- expectGoToDefinition (foo,1,[0..2]) (At (foo,2,0)) -- "foo" [see failing test "Go to definition takes type sig to definition"] + expectGoToDefinition (foo,1,[2..4]) Missing -- " : " + expectGoToDefinition (foo,1,[9]) Missing -- "\n" + expectGoToDefinition (foo,1,[10]) Missing -- (out of range) + expectGoToDefinition (foo,2,[0..2]) (At (foo,2,0)) -- "foo" + expectGoToDefinition (foo,2,[3..5]) Missing -- " = " + expectGoToDefinition (foo,2,[6..8]) (At (foo,4,0)) -- "bar" expectGoToDefinition (foo,2,[9]) Missing -- "\n" expectGoToDefinition (foo,2,[10]) Missing -- (out of range) - expectGoToDefinition (foo,3,[0..2]) (At (foo,3,0)) -- "foo" - expectGoToDefinition (foo,3,[3..5]) Missing -- " = " - expectGoToDefinition (foo,3,[6..8]) (At (foo,5,0)) -- "bar" - expectGoToDefinition (foo,3,[9]) Missing -- "\n" - expectGoToDefinition (foo,3,[10]) Missing -- (out of range) , testCase' "Go to definition across modules" $ do foo <- makeFile "Foo.daml" $ T.unlines - [ "daml 1.2" - , "module Foo where" + [ "module Foo where" , "import Bar" , "foo : Int" , "foo = bar" ] bar <- makeFile "Bar.daml" $ T.unlines - [ "daml 1.2" - , "module Bar where" + [ "module Bar where" , "bar : Int" , "bar = 10" ] setFilesOfInterest [foo, bar] expectNoErrors - expectGoToDefinition (foo,2,[7..9]) (At (bar,0,0)) -- "Bar" from "import Bar" - expectGoToDefinition (foo,4,[6..8]) (At (bar,3,0)) -- "bar" from "foo = bar" + expectGoToDefinition (foo,1,[7..9]) (At (bar,0,0)) -- "Bar" from "import Bar" + expectGoToDefinition (foo,3,[6..8]) (At (bar,2,0)) -- "bar" from "foo = bar" , testCase' "Go to definition handles touching identifiers" $ do foo <- makeFile "Foo.daml" $ T.unlines - [ "daml 1.2" - , "module Foo where" + [ "module Foo where" , "foo = bar+++baz" , "bar = 10" , "(+++) = (+)" @@ -646,9 +600,9 @@ goToDefinitionTests mbScenarioService = Tasty.testGroup "Go to definition tests" ] setFilesOfInterest [foo] expectNoErrors - expectGoToDefinition (foo,2,[6..8]) (At (foo,3,0)) -- "bar" - expectGoToDefinition (foo,2,[9..11]) (At (foo,4,0)) -- "+++" - expectGoToDefinition (foo,2,[12..14]) (At (foo,5,0)) -- "baz" + expectGoToDefinition (foo,1,[6..8]) (At (foo,2,0)) -- "bar" + expectGoToDefinition (foo,1,[9..11]) (At (foo,3,0)) -- "+++" + expectGoToDefinition (foo,1,[12..14]) (At (foo,4,0)) -- "baz" , testCase' "Take bound variable to its binding" $ do foo <- makeModule "Foo" @@ -658,69 +612,64 @@ goToDefinitionTests mbScenarioService = Tasty.testGroup "Go to definition tests" , " Some (x + y + z)" ] expectNoErrors - expectGoToDefinition (foo,5,[8]) (At (foo,3,4)) -- "x" - expectGoToDefinition (foo,5,[12]) (At (foo,3,9)) -- "y" - expectGoToDefinition (foo,5,[16]) (At (foo,4,2)) -- "z" + expectGoToDefinition (foo,4,[8]) (At (foo,2,4)) -- "x" + expectGoToDefinition (foo,4,[12]) (At (foo,2,9)) -- "y" + expectGoToDefinition (foo,4,[16]) (At (foo,3,2)) -- "z" , testCase' "Go to definition should be tight" $ do foo <- makeFile "Foo.daml" $ T.unlines - [ "daml 1.2" - , "module Foo where" + [ "module Foo where" , "foo = bar" , "bar=baz" , "baz = 10" ] setFilesOfInterest [foo] - expectGoToDefinition (foo,2,[0..2]) (At (foo,2,0)) - expectGoToDefinition (foo,2,[3..5]) Missing - expectGoToDefinition (foo,2,[6..8]) (At (foo,3,0)) - expectGoToDefinition (foo,2,[9]) Missing + expectGoToDefinition (foo,1,[0..2]) (At (foo,1,0)) + expectGoToDefinition (foo,1,[3..5]) Missing + expectGoToDefinition (foo,1,[6..8]) (At (foo,2,0)) + expectGoToDefinition (foo,1,[9]) Missing - expectGoToDefinition (foo,3,[0..2]) (At (foo,3,0)) - expectGoToDefinition (foo,3,[3]) Missing - expectGoToDefinition (foo,3,[4..6]) (At (foo,4,0)) - expectGoToDefinition (foo,3,[7]) Missing + expectGoToDefinition (foo,2,[0..2]) (At (foo,2,0)) + expectGoToDefinition (foo,2,[3]) Missing + expectGoToDefinition (foo,2,[4..6]) (At (foo,3,0)) + expectGoToDefinition (foo,2,[7]) Missing , testCaseFails' "Go to definition takes type sig to definition" $ do foo <- makeFile "Foo.daml" $ T.unlines - [ "daml 1.2" - , "module Foo where" + [ "module Foo where" , "foo : Int" , "foo = 0" ] setFilesOfInterest [foo] - expectGoToDefinition (foo,2,[0]) (At (foo,3,0)) + expectGoToDefinition (foo,1,[0]) (At (foo,2,0)) , testCase' "Go to definition on type in type sig" $ do foo <- makeFile "Foo.daml" $ T.unlines - [ "daml 1.2" - , "module Foo where" + [ "module Foo where" , "data X = X {}" , "foo : X" , "foo = X" ] setFilesOfInterest [foo] - expectGoToDefinition (foo,3,[6]) (At (foo,2,0)) + expectGoToDefinition (foo,2,[6]) (At (foo,1,0)) , testCase' "Go to definition on type annotation" $ do foo <- makeFile "Foo.daml" $ T.unlines - [ "daml 1.2" - , "module Foo where" + [ "module Foo where" , "data X = X {}" , "foo : X" , "foo = X : X" ] setFilesOfInterest [foo] - expectGoToDefinition (foo,4,[10]) (At (foo,2,0)) + expectGoToDefinition (foo,3,[10]) (At (foo,1,0)) , testCase' "Go to definition should ignore negative column" $ do foo <- makeFile "Foo.daml" $ T.unlines - [ "daml 1.2" - , "module Foo where" + [ "module Foo where" , "foo = 10" ] setFilesOfInterest [foo] - expectGoToDefinition (foo,2,[-1]) Missing + expectGoToDefinition (foo,1,[-1]) Missing , testCaseFails' "Take variable in template to its declaration" $ do foo <- makeModule "Foo" @@ -734,10 +683,10 @@ goToDefinitionTests mbScenarioService = Tasty.testGroup "Go to definition tests" setFilesOfInterest [foo] expectNoErrors -- This actually ends up pointing to "concat". - expectGoToDefinition (foo,6,[14..18]) (At (foo,4,4)) -- "owner" in signatory clause - -- We do have a codespan for "owner" at (7,[19..23]) - -- but we report (7,[4..41]) as the definition for it. - expectGoToDefinition (foo,7,[19..23]) (At (foo,4,4)) -- "owner" in agreement + expectGoToDefinition (foo,5,[14..18]) (At (foo,3,4)) -- "owner" in signatory clause + -- We do have a codespan for "owner" at (6,[19..23]) + -- but we report (6,[4..41]) as the definition for it. + expectGoToDefinition (foo,6,[19..23]) (At (foo,3,4)) -- "owner" in agreement , testCase' "Standard library type points to standard library" $ do foo <- makeModule "Foo" @@ -746,15 +695,14 @@ goToDefinitionTests mbScenarioService = Tasty.testGroup "Go to definition tests" ] setFilesOfInterest [foo] expectNoErrors - expectGoToDefinition (foo,2,[6..13]) (In "Prelude") -- "Optional" - expectGoToDefinition (foo,2,[16..19]) (In "DA.Internal.Compatible") -- "List" + expectGoToDefinition (foo,1,[6..13]) (In "Prelude") -- "Optional" + expectGoToDefinition (foo,1,[16..19]) (In "DA.Internal.Compatible") -- "List" -- Bool is from GHC.Types which is wired into the compiler - expectGoToDefinition (foo,2,[20]) Missing + expectGoToDefinition (foo,1,[20]) Missing , testCase' "Go to definition takes export list to definition" $ do foo <- makeFile "Foo.daml" $ T.unlines - [ "daml 1.2" - , "module Foo (foo, A(B)) where" + [ "module Foo (foo, A(B)) where" , "foo : Int" , "foo = 0" , "data A = B Int" @@ -762,11 +710,11 @@ goToDefinitionTests mbScenarioService = Tasty.testGroup "Go to definition tests" setFilesOfInterest [foo] expectNoErrors -- foo - expectGoToDefinition (foo,1,[13..14]) (At (foo,3,0)) + expectGoToDefinition (foo,0,[13..14]) (At (foo,2,0)) -- A - expectGoToDefinition (foo,1,[17..17]) (At (foo,4,0)) + expectGoToDefinition (foo,0,[17..17]) (At (foo,3,0)) -- B - expectGoToDefinition (foo,1,[19..19]) (At (foo,4,9)) + expectGoToDefinition (foo,0,[19..19]) (At (foo,3,9)) , testCase' "Cross-package goto definition" $ do foo <- makeModule "Foo" @@ -776,7 +724,7 @@ goToDefinitionTests mbScenarioService = Tasty.testGroup "Go to definition tests" ] setFilesOfInterest [foo] expectNoErrors - expectGoToDefinition (foo, 3, [7..14]) (In "DA.Internal.LF") + expectGoToDefinition (foo, 2, [7..14]) (In "DA.Internal.LF") ] where testCase' = testCase mbScenarioService @@ -786,27 +734,26 @@ onHoverTests :: Maybe SS.Handle -> Tasty.TestTree onHoverTests mbScenarioService = Tasty.testGroup "On hover tests" [ testCase' "Type for uses but not for definitions" $ do f <- makeFile "F.daml" $ T.unlines - [ "daml 1.2" - , "module F where" + [ "module F where" , "inc: Int -> Int" , "inc x = x + 1" , "six: Int" , "six = inc 5" ] setFilesOfInterest [f] - expectTextOnHover (f,2,[0..2]) NoInfo -- signature of inc - expectTextOnHover (f,3,[0..2]) $ HasType "Int -> Int" -- definition of inc - expectTextOnHover (f,3,[4]) $ HasType "Int" -- binding of x - expectTextOnHover (f,4,[0..2]) NoInfo -- signature of six - expectTextOnHover (f,5,[0..2]) $ HasType "Int" -- definition of six - expectTextOnHover (f,5,[6..8]) $ HasType "Int -> Int" -- use of inc + expectTextOnHover (f,1,[0..2]) NoInfo -- signature of inc + expectTextOnHover (f,2,[0..2]) $ HasType "Int -> Int" -- definition of inc + expectTextOnHover (f,2,[4]) $ HasType "Int" -- binding of x + expectTextOnHover (f,3,[0..2]) NoInfo -- signature of six + expectTextOnHover (f,4,[0..2]) $ HasType "Int" -- definition of six + expectTextOnHover (f,4,[6..8]) $ HasType "Int -> Int" -- use of inc , testCase' "Type of variable bound in function definition" $ do f <- makeModule "F" [ "f: Int -> Int" , "f x = x + 1" ] setFilesOfInterest [f] - expectTextOnHover (f,3,[6]) $ HasType "Int" -- use of x + expectTextOnHover (f,2,[6]) $ HasType "Int" -- use of x , testCase' "Type of literals" $ do f <- makeModule "F" @@ -814,8 +761,8 @@ onHoverTests mbScenarioService = Tasty.testGroup "On hover tests" , "f x = x + 110" , "hello = \"hello\"" ] setFilesOfInterest [f] - expectTextOnHover (f,3,[10..12]) $ HasType "Int" -- literal 110 - expectTextOnHover (f,4,[8..14]) $ HasType "Text" -- literal "hello" + expectTextOnHover (f,2,[10..12]) $ HasType "Int" -- literal 110 + expectTextOnHover (f,3,[8..14]) $ HasType "Text" -- literal "hello" , testCase' "Type of party" $ do f <- makeModule "F" @@ -824,7 +771,7 @@ onHoverTests mbScenarioService = Tasty.testGroup "On hover tests" , " submit alice $ pure ()" ] setFilesOfInterest [f] - expectTextOnHover (f,4,[9..13]) $ HasType "Party" -- use of alice + expectTextOnHover (f,3,[9..13]) $ HasType "Party" -- use of alice , testCaseFails' "Type of signatories" $ do f <- makeModule "F" @@ -835,7 +782,7 @@ onHoverTests mbScenarioService = Tasty.testGroup "On hover tests" , " signatory issuer" ] setFilesOfInterest [f] - expectTextOnHover (f,6,[14..19]) $ HasType "Party" -- issuer in signatory clause + expectTextOnHover (f,5,[14..19]) $ HasType "Party" -- issuer in signatory clause , testCase' "Hover over choice does not display `==` or `show`" $ do f <- makeModule "F" @@ -852,10 +799,10 @@ onHoverTests mbScenarioService = Tasty.testGroup "On hover tests" , " do create this with owner = newOwner" ] setFilesOfInterest [f] - expectTextOnHover (f,8,[6..11]) $ NotContaining "==" -- Delete choice - expectTextOnHover (f,8,[6..11]) $ NotContaining "show" - expectTextOnHover (f,10,[6..13]) $ NotContaining "==" -- Transfer choice - expectTextOnHover (f,10,[6..13]) $ NotContaining "show" + expectTextOnHover (f,7,[6..11]) $ NotContaining "==" -- Delete choice + expectTextOnHover (f,7,[6..11]) $ NotContaining "show" + expectTextOnHover (f,9,[6..13]) $ NotContaining "==" -- Transfer choice + expectTextOnHover (f,9,[6..13]) $ NotContaining "show" , testCase' "Type of user-defined == and show functions" $ do f <- makeModule "F" @@ -865,8 +812,8 @@ onHoverTests mbScenarioService = Tasty.testGroup "On hover tests" , "show b = 2" ] setFilesOfInterest [f] - expectTextOnHover (f,3,[0..3]) $ Contains "```daml\n==\n: Text -> Bool\n```\n" - expectTextOnHover (f,5,[0..3]) $ Contains "```daml\nshow\n: Bool -> Int\n```\n" + expectTextOnHover (f,2,[0..3]) $ Contains "```daml\n==\n: Text -> Bool\n```\n" + expectTextOnHover (f,4,[0..3]) $ Contains "```daml\nshow\n: Bool -> Int\n```\n" , testCaseFails' "Type of choice" $ do f <- makeModule "F" @@ -883,8 +830,8 @@ onHoverTests mbScenarioService = Tasty.testGroup "On hover tests" , " do create this with owner = newOwner" ] setFilesOfInterest [f] - expectTextOnHover (f,8,[6..11]) $ HasType "Update ()" -- Delete choice - expectTextOnHover (f,10,[6..13]) $ HasType "Party -> Update (ContractId Coin)" -- Transfer choice + expectTextOnHover (f,7,[6..11]) $ HasType "Update ()" -- Delete choice + expectTextOnHover (f,9,[6..13]) $ HasType "Party -> Update (ContractId Coin)" -- Transfer choice , testCase' "Haddock comment" $ do f <- makeModule "F" [ "-- | Important docs" @@ -893,7 +840,7 @@ onHoverTests mbScenarioService = Tasty.testGroup "On hover tests" ] setFilesOfInterest [f] expectNoErrors - expectTextOnHover (f,4,[0]) $ Contains "Important docs" + expectTextOnHover (f,3,[0]) $ Contains "Important docs" ] where testCase' = testCase mbScenarioService @@ -903,8 +850,7 @@ scenarioTests :: Maybe SS.Handle -> Tasty.TestTree scenarioTests mbScenarioService = Tasty.testGroup "Scenario tests" [ testCase' "Run an empty scenario" $ do let fooContent = T.unlines - [ "daml 1.2" - , "module Foo where" + [ "module Foo where" , "v = scenario do" , " pure ()" ] @@ -916,8 +862,7 @@ scenarioTests mbScenarioService = Tasty.testGroup "Scenario tests" expectVirtualResource vr "Return value: {}" , testCase' "Run a scenario with a failing assertion" $ do let fooContent = T.unlines - [ "daml 1.2" - , "module Foo where" + [ "module Foo where" , "v = scenario do" , " assert False" ] @@ -925,12 +870,11 @@ scenarioTests mbScenarioService = Tasty.testGroup "Scenario tests" let vr = VRScenario foo "v" setFilesOfInterest [foo] setOpenVirtualResources [vr] - expectOneError (foo,2,0) "Aborted: Assertion failed" + expectOneError (foo,1,0) "Aborted: Assertion failed" expectVirtualResource vr "Aborted: Assertion failed" , testCase' "Virtual resources should update when files update" $ do let fooContent = T.unlines - [ "daml 1.2" - , "module Foo where" + [ "module Foo where" , "v = scenario $ assert True" ] foo <- makeFile "Foo.daml" fooContent @@ -939,15 +883,13 @@ scenarioTests mbScenarioService = Tasty.testGroup "Scenario tests" setOpenVirtualResources [vr] expectVirtualResource vr "Return value: {}" setBufferModified foo $ T.unlines - [ "daml 1.2" - , "module Foo where" + [ "module Foo where" , "v = scenario $ assert False" ] expectVirtualResource vr "Aborted: Assertion failed" , testCase' "Scenario error disappears when scenario is deleted" $ do let goodScenario = - [ "daml 1.2" - , "module F where" + [ "module F where" , "example1 = scenario $ assert True" ] badScenario = [ "example2 = scenario $ assert False" ] @@ -960,25 +902,22 @@ scenarioTests mbScenarioService = Tasty.testGroup "Scenario tests" setBufferModified f $ T.unlines $ goodScenario ++ badScenario let vr2 = VRScenario f "example2" setOpenVirtualResources [vr1, vr2] - expectOneError (f, 3, 0) "Scenario execution failed" + expectOneError (f, 2, 0) "Scenario execution failed" expectVirtualResource vr2 "Aborted: Assertion failed" setBufferModified f $ T.unlines goodScenario expectNoErrors expectVirtualResource vr1 "Return value: {}" , testCase' "Virtual resource gets updated with a note when file compiles, but scenario is no longer present" $ do let scenario1F = - [ "daml 1.2" - , "module F where" + [ "module F where" , "scenario1 = scenario $ pure \"f1\"" ] scenario1G = - [ "daml 1.2" - , "module G where" + [ "module G where" , "scenario1 = scenario $ pure \"g1\"" ] scenario12F = - [ "daml 1.2" - , "module F where" + [ "module F where" , "scenario1 = scenario $ pure \"f1\"" , "scenario2 = scenario $ pure \"f2\"" ] @@ -1026,18 +965,15 @@ scenarioTests mbScenarioService = Tasty.testGroup "Scenario tests" expectNoVirtualResourceNote vr1G , testCase' "Virtual resource gets updated with a note when file does not compile anymore" $ do let scenario1F = - [ "daml 1.2" - , "module F where" + [ "module F where" , "scenario1 = scenario $ pure \"f1\"" ] scenario1G = - [ "daml 1.2" - , "module G where" + [ "module G where" , "scenario1 = scenario $ pure \"g1\"" ] scenario1FInvalid = - [ "daml 1.2" - , "module F where" + [ "module F where" , "this is bad syntax" ] f <- makeFile "F.daml" $ T.unlines scenario1F @@ -1058,7 +994,7 @@ scenarioTests mbScenarioService = Tasty.testGroup "Scenario tests" setBufferModified f $ T.unlines scenario1FInvalid setOpenVirtualResources [vr1F, vr1G] - expectOneError (f,2,0) "Parse error" + expectOneError (f,1,0) "Parse error" expectVirtualResource vr1F "Return value: "f1"" expectVirtualResourceNote vr1F "The source file containing this scenario no longer compiles" @@ -1074,8 +1010,7 @@ scenarioTests mbScenarioService = Tasty.testGroup "Scenario tests" expectVirtualResource vr1G "Return value: "g1"" , testCase' "Scenario in file of interest but not opened" $ do let fooContent = T.unlines - [ "daml 1.2" - , "module Foo where" + [ "module Foo where" , "v = scenario $ assert False" ] foo <- makeFile "Foo.daml" fooContent @@ -1083,12 +1018,11 @@ scenarioTests mbScenarioService = Tasty.testGroup "Scenario tests" setFilesOfInterest [foo] setOpenVirtualResources [] -- We expect to get the diagnostic here but no virtual resource. - expectOneError (foo,2,0) "Aborted: Assertion failed" + expectOneError (foo,1,0) "Aborted: Assertion failed" expectNoVirtualResource vr , testCase' "Scenario opened but not in files of interest" $ do foo <- makeFile "Foo.daml" $ T.unlines - [ "daml 1.2" - , "module Foo where" + [ "module Foo where" , "v = scenario $ assert True" ] let vr = VRScenario foo "v" @@ -1097,14 +1031,12 @@ scenarioTests mbScenarioService = Tasty.testGroup "Scenario tests" expectVirtualResource vr "Return value: {}" , testCase' "Update dependency of open scenario that is not in files of interest" $ do let fooContent = T.unlines - [ "daml 1.2" - , "module Foo where" + [ "module Foo where" , "import Bar" , "v = scenario $ bar ()" ] barContent = T.unlines - [ "daml 1.2" - , "module Bar where" + [ "module Bar where" , "bar : () -> Scenario ()" , "bar () = assert True" ] @@ -1115,17 +1047,15 @@ scenarioTests mbScenarioService = Tasty.testGroup "Scenario tests" expectNoErrors expectVirtualResource vr "Return value: {}" setBufferModified bar $ T.unlines - [ "daml 1.2" - , "module Bar where" + [ "module Bar where" , "bar : () -> Scenario ()" , "bar _ = assert False" ] - expectOneError (foo,3,0) "Aborted: Assertion failed" + expectOneError (foo,2,0) "Aborted: Assertion failed" expectVirtualResource vr "Aborted: Assertion failed" , testCase' "Open scenario after scenarios have already been run" $ do foo <- makeFile "Foo.daml" $ T.unlines - [ "daml 1.2" - , "module Foo where" + [ "module Foo where" , "v= scenario $ assert True" ] let vr = VRScenario foo "v" @@ -1135,8 +1065,7 @@ scenarioTests mbScenarioService = Tasty.testGroup "Scenario tests" expectVirtualResource vr "Return value: {}" , testCase' "Failing scenario produces stack trace in correct order" $ do let fooContent = T.unlines - [ "daml 1.2" - , "module Foo where" + [ "module Foo where" , "boom = fail \"BOOM\"" , "test : Scenario ()" , "test = boom" @@ -1146,7 +1075,7 @@ scenarioTests mbScenarioService = Tasty.testGroup "Scenario tests" let vr = VRScenario foo "test" setFilesOfInterest [foo] setOpenVirtualResources [vr] - expectVirtualResourceRegex vr "Stack trace:.*- boom.*Foo:3:1.*- test.*Foo:5:1" + expectVirtualResourceRegex vr "Stack trace:.*- boom.*Foo:2:1.*- test.*Foo:4:1" , testCase' "HasCallStack constraint" $ do let fooContent = T.unlines [ "module Foo where" @@ -1171,8 +1100,7 @@ scenarioTests mbScenarioService = Tasty.testGroup "Scenario tests" ] , testCase' "debug is lazy" $ do let goodScenario = - [ "daml 1.2" - , "module LazyDebug where" + [ "module LazyDebug where" , "import DA.Foldable" , "import DA.Action.State" diff --git a/compiler/damlc/tests/src/DamlcTest.hs b/compiler/damlc/tests/src/DamlcTest.hs index b939b22f335..376fad76511 100644 --- a/compiler/damlc/tests/src/DamlcTest.hs +++ b/compiler/damlc/tests/src/DamlcTest.hs @@ -53,7 +53,7 @@ testsForDamlcValidate damlc = testGroup "damlc validate-dar" , "dependencies: [daml-prim, daml-stdlib]" ] writeFileUTF8 (projDir "Good.daml") $ unlines - [ "daml 1.2 module Good where" + [ "module Good where" , "good = 1 + 2" ] step "build" @@ -75,7 +75,7 @@ testsForDamlcValidate damlc = testGroup "damlc validate-dar" , "dependencies: [daml-prim, daml-stdlib]" ] writeFileUTF8 (projDir "Good.daml") $ unlines - [ "daml 1.2 module Good where" + [ "module Good where" , "template MyT" , " with" , " myParty : Party" @@ -101,7 +101,7 @@ testsForDamlcValidate damlc = testGroup "damlc validate-dar" , "dependencies: [daml-prim, daml-stdlib]" ] writeFileUTF8 (projDir "Good.daml") $ unlines - [ "daml 1.2 module Good where" + [ "module Good where" , "good = 1" ] step "build" @@ -131,7 +131,7 @@ testsForDamlcValidate damlc = testGroup "damlc validate-dar" , "dependencies: [daml-prim, daml-stdlib]" ] writeFileUTF8 (projDir "Good.daml") $ unlines - [ "daml 1.2 module Good where" + [ "module Good where" , "good = 1" ] step "build" @@ -163,8 +163,7 @@ testsForDamlcTest damlc = testGroup "damlc test" $ withTempDir $ \dir -> do let file = dir "Foo.daml" T.writeFileUtf8 file $ T.unlines - [ "daml 1.2" - , "module Foo where" + [ "module Foo where" , "abc" ] (exitCode, stdout, stderr) <- readProcessWithExitCode damlc ["test", "--files", file] "" @@ -175,8 +174,7 @@ testsForDamlcTest damlc = testGroup "damlc test" $ withTempDir $ \dir -> do let file = dir "Foo.daml" T.writeFileUtf8 file $ T.unlines - [ "daml 1.2" - , "module Foo where" + [ "module Foo where" , "x = scenario $ assert False" ] (exitCode, stdout, stderr) <- readProcessWithExitCode damlc ["test", "--files", file] "" @@ -185,8 +183,7 @@ testsForDamlcTest damlc = testGroup "damlc test" $ exitCode @?= ExitFailure 1 , testCase "damlc test --files outside of project" $ withTempDir $ \projDir -> do writeFileUTF8 (projDir "Main.daml") $ unlines - [ "daml 1.2" - , "module Main where" + [ "module Main where" , "test = scenario do" , " assert True" ] @@ -197,8 +194,7 @@ testsForDamlcTest damlc = testGroup "damlc test" $ , testCase "damlc test --project-root relative" $ withTempDir $ \projDir -> do createDirectoryIfMissing True (projDir "relative") writeFileUTF8 (projDir "relative" "Main.daml") $ unlines - [ "daml 1.2" - , "module Main where" + [ "module Main where" , "test = scenario do" , " assert True" ] @@ -222,7 +218,7 @@ testsForDamlcTest damlc = testGroup "damlc test" $ , "dependencies: [daml-prim, daml-stdlib]" ] writeFileUTF8 (projDir "a" "A.daml") $ unlines - [ "daml 1.2 module A where" + [ "module A where" , "a = 1" ] callProcessSilent damlc ["build", "--project-root", projDir "a"] @@ -235,7 +231,7 @@ testsForDamlcTest damlc = testGroup "damlc test" $ , "dependencies: [daml-prim, daml-stdlib, " <> show (projDir "a/.daml/dist/a-0.0.1.dar") <> "]" ] writeFileUTF8 (projDir "b" "B.daml") $ unlines - [ "daml 1.2 module B where" + [ "module B where" , "import A" , "b = a" , "test = scenario do" diff --git a/compiler/damlc/tests/src/daml-ghc-deterministic.sh b/compiler/damlc/tests/src/daml-ghc-deterministic.sh index c60aedccfa9..761497b1ad9 100755 --- a/compiler/damlc/tests/src/daml-ghc-deterministic.sh +++ b/compiler/damlc/tests/src/daml-ghc-deterministic.sh @@ -76,7 +76,6 @@ dependencies: [daml-prim, daml-stdlib] EOF cat < "$PROJDIR/A.daml" -daml 1.2 module A where EOF diff --git a/compiler/lsp-tests/src/Main.hs b/compiler/lsp-tests/src/Main.hs index 804d2ba7360..d12f0487f02 100644 --- a/compiler/lsp-tests/src/Main.hs +++ b/compiler/lsp-tests/src/Main.hs @@ -78,27 +78,23 @@ diagnosticTests diagnosticTests run runScenarios = testGroup "diagnostics" [ testCase "diagnostics disappear after error is fixed" $ run $ do test <- openDoc' "Test.daml" damlId $ T.unlines - [ "daml 1.2" - , "module Test where" + [ "module Test where" , "f 1" ] - expectDiagnostics [("Test.daml", [(DsError, (2, 0), "Parse error")])] + expectDiagnostics [("Test.daml", [(DsError, (1, 0), "Parse error")])] replaceDoc test $ T.unlines - [ "daml 1.2" - , "module Test where" + [ "module Test where" , "f = ()" ] expectDiagnostics [("Test.daml", [])] closeDoc test , testCase "lower-case drive" $ run $ do let aContent = T.unlines - [ "daml 1.2" - , "module A.A where" + [ "module A.A where" , "import A.B ()" ] bContent = T.unlines - [ "daml 1.2" - , "module A.B where" + [ "module A.B where" , "import DA.List" ] uriB <- getDocUri "A/B.daml" @@ -127,38 +123,33 @@ diagnosticTests run runScenarios = testGroup "diagnostics" closeDoc a , testCase "diagnostics appear after introducing an error" $ run $ do test <- openDoc' "Test.daml" damlId $ T.unlines - [ "daml 1.2" - , "module Test where" + [ "module Test where" , "f = ()" ] replaceDoc test $ T.unlines - [ "daml 1.2" - , "module Test where" + [ "module Test where" , "f 1" ] - expectDiagnostics [("Test.daml", [(DsError, (2, 0), "Parse error")])] + expectDiagnostics [("Test.daml", [(DsError, (1, 0), "Parse error")])] closeDoc test , testCase "percent encoding does not matter" $ run $ do Just uri <- parseURI . T.unpack . getUri <$> getDocUri "Test.daml" let weirdUri = Uri $ T.pack $ "file://" <> escapeURIString (== '/') (uriPath uri) let item = TextDocumentItem weirdUri (T.pack damlId) 0 $ T.unlines - [ "daml 1.2" - , "module Test where" + [ "module Test where" , "f = ()" ] sendNotification TextDocumentDidOpen (DidOpenTextDocumentParams item) let test = TextDocumentIdentifier weirdUri replaceDoc test $ T.unlines - [ "daml 1.2" - , "module Test where" + [ "module Test where" , "f 1" ] - expectDiagnostics [("Test.daml", [(DsError, (2, 0), "Parse error")])] + expectDiagnostics [("Test.daml", [(DsError, (1, 0), "Parse error")])] closeDoc test , testCase "failed name resolution" $ run $ do main' <- openDoc' "Main.daml" damlId $ T.unlines - [ "daml 1.2" - , "module Main where" + [ "module Main where" , "add : Int -> Int -> Int" , "add a b = ab + b" , "succ : Int -> Int" @@ -166,64 +157,58 @@ diagnosticTests run runScenarios = testGroup "diagnostics" ] expectDiagnostics [ ( "Main.daml" - , [ (DsError, (3, 10), "Variable not in scope: ab") - , (DsError, (5, 7), "Variable not in scope: abdd") + , [ (DsError, (2, 10), "Variable not in scope: ab") + , (DsError, (4, 7), "Variable not in scope: abdd") ] ) ] closeDoc main' , testCase "import cycle" $ run $ do let aContent = T.unlines - [ "daml 1.2" - , "module A where" + [ "module A where" , "import B" ] bContent = T.unlines - [ "daml 1.2" - , "module B where" + [ "module B where" , "import A" ] [a, b] <- openDocs damlId [("A.daml", aContent), ("B.daml", bContent)] expectDiagnostics [ ( "A.daml" - , [(DsError, (2, 7), "Cyclic module dependency between A, B")] + , [(DsError, (1, 7), "Cyclic module dependency between A, B")] ) , ( "B.daml" - , [(DsError, (2, 7), "Cyclic module dependency between A, B")] + , [(DsError, (1, 7), "Cyclic module dependency between A, B")] ) ] closeDoc b closeDoc a , testCase "import error" $ run $ do main' <- openDoc' "Main.daml" damlId $ T.unlines - [ "daml 1.2" - , "module Main where" + [ "module Main where" , "import Oops" ] expectDiagnostics - [("Main.daml", [(DsError, (2, 7), "Could not find module 'Oops'")])] + [("Main.daml", [(DsError, (1, 7), "Could not find module 'Oops'")])] closeDoc main' , testCase "multi module funny" $ run $ do libsC <- openDoc' "Libs/C.daml" damlId $ T.unlines - [ "daml 1.2" - , "module Libs.C where" + [ "module Libs.C where" ] libsB <- openDoc' "Libs/B.daml" damlId $ T.unlines - [ "daml 1.2" - , "module Libs.B where" + [ "module Libs.B where" , "import Libs.C" ] libsA <- openDoc' "Libs/A.daml" damlId $ T.unlines - [ "daml 1.2" - , "module Libs.A where" + [ "module Libs.A where" , "import C" ] expectDiagnostics [ ( "Libs/A.daml" - , [(DsError, (2, 7), "Could not find module 'C'")] + , [(DsError, (1, 7), "Could not find module 'C'")] ) , ( "Libs/B.daml" - , [(DsWarning, (2, 0), "import of 'Libs.C' is redundant")] + , [(DsWarning, (1, 0), "import of 'Libs.C' is redundant")] ) ] closeDoc libsA @@ -231,22 +216,20 @@ diagnosticTests run runScenarios = testGroup "diagnostics" closeDoc libsC , testCase "parse error" $ run $ do test <- openDoc' "Test.daml" damlId $ T.unlines - [ "daml 1.2" - , "module Test where" + [ "module Test where" , "f 1" ] - expectDiagnostics [("Test.daml", [(DsError, (2, 0), "Parse error")])] + expectDiagnostics [("Test.daml", [(DsError, (1, 0), "Parse error")])] closeDoc test , testCase "type error" $ run $ do main' <- openDoc' "Main.daml" damlId $ T.unlines - [ "daml 1.2" - , "module Main where" + [ "module Main where" , "oops = 1 + \"foo\"" ] expectDiagnostics [ ( "Main.daml" , [ ( DsError - , (2, 11) + , (1, 11) , "Couldn't match expected type 'Int' with actual type 'Text'" ) ] @@ -255,8 +238,7 @@ diagnosticTests run runScenarios = testGroup "diagnostics" closeDoc main' , testCase "scenario error" $ runScenarios $ do main' <- openDoc' "Main.daml" damlId $ T.unlines - [ "daml 1.2" - , "module Main where" + [ "module Main where" , "template Agree with p1 : Party; p2 : Party where" , " signatory [p1, p2]" , "myScenario = scenario do" @@ -266,7 +248,7 @@ diagnosticTests run runScenarios = testGroup "diagnostics" ] expectDiagnostics [ ( "Main.daml" - , [(DsError, (4, 0), "missing authorization from 'Alice'")] + , [(DsError, (3, 0), "missing authorization from 'Alice'")] ) ] closeDoc main' @@ -280,8 +262,7 @@ requestTests requestTests run _runScenarios = testGroup "requests" [ testCase "code-lenses" $ run $ do main' <- openDoc' "Main.daml" damlId $ T.unlines - [ "daml 1.2" - , "module Main where" + [ "module Main where" , "single = scenario do" , " assert (True == True)" ] @@ -289,7 +270,7 @@ requestTests run _runScenarios = testGroup "requests" Just escapedFp <- pure $ escapeURIString isUnescapedInURIComponent <$> uriToFilePath (main' ^. uri) liftIO $ lenses @?= [ CodeLens - { _range = Range (Position 2 0) (Position 2 6) + { _range = Range (Position 1 0) (Position 1 6) , _command = Just $ Command { _title = "Scenario results" , _command = "daml.showResource" @@ -305,8 +286,7 @@ requestTests run _runScenarios = testGroup "requests" closeDoc main' , testCase "stale code-lenses" $ run $ do main' <- openDoc' "Main.daml" damlId $ T.unlines - [ "daml 1.2" - , "module Main where" + [ "module Main where" , "single = scenario do" , " assert True" ] @@ -325,20 +305,19 @@ requestTests run _runScenarios = testGroup "requests" } , _xdata = Nothing } - liftIO $ lenses @?= [codeLens (Range (Position 2 0) (Position 2 6))] - changeDoc main' [TextDocumentContentChangeEvent (Just (Range (Position 3 23) (Position 3 23))) Nothing "+"] - expectDiagnostics [("Main.daml", [(DsError, (4, 0), "Parse error")])] + liftIO $ lenses @?= [codeLens (Range (Position 1 0) (Position 1 6))] + changeDoc main' [TextDocumentContentChangeEvent (Just (Range (Position 2 23) (Position 2 23))) Nothing "+"] + expectDiagnostics [("Main.daml", [(DsError, (3, 0), "Parse error")])] lenses <- getCodeLenses main' - liftIO $ lenses @?= [codeLens (Range (Position 2 0) (Position 2 6))] + liftIO $ lenses @?= [codeLens (Range (Position 1 0) (Position 1 6))] -- Shift code lenses down - changeDoc main' [TextDocumentContentChangeEvent (Just (Range (Position 1 0) (Position 1 0))) Nothing "\n\n"] + changeDoc main' [TextDocumentContentChangeEvent (Just (Range (Position 0 0) (Position 0 0))) Nothing "\n\n"] lenses <- getCodeLenses main' - liftIO $ lenses @?= [codeLens (Range (Position 4 0) (Position 4 6))] + liftIO $ lenses @?= [codeLens (Range (Position 3 0) (Position 3 6))] closeDoc main' , testCase "type on hover: name" $ run $ do main' <- openDoc' "Main.daml" damlId $ T.unlines - [ "daml 1.2" - , "module Main where" + [ "module Main where" , "add : Int -> Int -> Int" , "add a b = a + b" , "template DoStuff with party : Party where" @@ -349,7 +328,7 @@ requestTests run _runScenarios = testGroup "requests" , " do pure (add 5 number)" ] Just fp <- pure $ uriToFilePath (main' ^. uri) - r <- getHover main' (Position 9 19) + r <- getHover main' (Position 8 19) liftIO $ r @?= Just Hover { _contents = HoverContents $ MarkupContent MkMarkdown $ T.unlines [ "```daml" @@ -357,19 +336,18 @@ requestTests run _runScenarios = testGroup "requests" , ": Int -> Int -> Int" , "```" , "*\t*\t*" - , "*Defined at " <> T.pack fp <> ":4:1*" + , "*Defined at " <> T.pack fp <> ":3:1*" ] - , _range = Just $ Range (Position 9 17) (Position 9 20) + , _range = Just $ Range (Position 8 17) (Position 8 20) } closeDoc main' , testCase "type on hover: literal" $ run $ do main' <- openDoc' "Main.daml" damlId $ T.unlines - [ "daml 1.2" - , "module Main where" + [ "module Main where" , "simple arg1 = let xlocal = 1.0 in xlocal + arg1" ] - r <- getHover main' (Position 2 27) + r <- getHover main' (Position 1 27) liftIO $ r @?= Just Hover { _contents = HoverContents $ MarkupContent MkMarkdown $ T.unlines [ "```daml" @@ -379,18 +357,16 @@ requestTests run _runScenarios = testGroup "requests" , "```" , "*\t*\t*" ] - , _range = Just $ Range (Position 2 27) (Position 2 30) + , _range = Just $ Range (Position 1 27) (Position 1 30) } closeDoc main' , testCase "definition" $ run $ do test <- openDoc' "Test.daml" damlId $ T.unlines - [ "daml 1.2" - , "module Test where" + [ "module Test where" , "answerFromTest = 42" ] main' <- openDoc' "Main.daml" damlId $ T.unlines - [ "daml 1.2" - , "module Main where" + [ "module Main where" , "import Test" , "bar = answerFromTest" , "foo thisIsAParam = thisIsAParam <> \" concatenated with a Text.\"" @@ -407,20 +383,20 @@ requestTests run _runScenarios = testGroup "requests" , " pure ()" ] -- thisIsAParam - locs <- getDefinitions main' (Position 4 24) - liftIO $ locs @?= [Location (main' ^. uri) (Range (Position 4 4) (Position 4 16))] + locs <- getDefinitions main' (Position 3 24) + liftIO $ locs @?= [Location (main' ^. uri) (Range (Position 3 4) (Position 3 16))] -- letParam - locs <- getDefinitions main' (Position 5 37) - liftIO $ locs @?= [Location (main' ^. uri) (Range (Position 5 16) (Position 5 24))] + locs <- getDefinitions main' (Position 4 37) + liftIO $ locs @?= [Location (main' ^. uri) (Range (Position 4 16) (Position 4 24))] -- import Test - locs <- getDefinitions main' (Position 2 10) + locs <- getDefinitions main' (Position 1 10) liftIO $ locs @?= [Location (test ^. uri) (Range (Position 0 0) (Position 0 0))] -- use of `bar` in template - locs <- getDefinitions main' (Position 14 20) - liftIO $ locs @?= [Location (main' ^. uri) (Range (Position 3 0) (Position 3 3))] + locs <- getDefinitions main' (Position 13 20) + liftIO $ locs @?= [Location (main' ^. uri) (Range (Position 2 0) (Position 2 3))] -- answerFromTest - locs <- getDefinitions main' (Position 3 8) - liftIO $ locs @?= [Location (test ^. uri) (Range (Position 2 0) (Position 2 14))] + locs <- getDefinitions main' (Position 2 8) + liftIO $ locs @?= [Location (test ^. uri) (Range (Position 1 0) (Position 1 14))] closeDoc main' closeDoc test ] @@ -429,15 +405,14 @@ scenarioTests :: (Session () -> IO ()) -> TestTree scenarioTests run = testGroup "scenarios" [ testCase "opening codelens produces a notification" $ run $ do main' <- openDoc' "Main.daml" damlId $ T.unlines - [ "daml 1.2" - , "module Main where" + [ "module Main where" , "main = scenario $ assert (True == True)" ] lenses <- getCodeLenses main' uri <- scenarioUri "Main.daml" "main" liftIO $ lenses @?= [ CodeLens - { _range = Range (Position 2 0) (Position 2 4) + { _range = Range (Position 1 0) (Position 1 4) , _command = Just $ Command { _title = "Scenario results" , _command = "daml.showResource" @@ -454,8 +429,7 @@ scenarioTests run = testGroup "scenarios" closeDoc mainScenario , testCase "scenario ok" $ run $ do main' <- openDoc' "Main.daml" damlId $ T.unlines - [ "daml 1.2" - , "module Main where" + [ "module Main where" , "main = scenario $ pure \"ok\"" ] scenario <- openScenario "Main.daml" "main" @@ -464,8 +438,7 @@ scenarioTests run = testGroup "scenarios" closeDoc main' , testCase "spaces in path" $ run $ do main' <- openDoc' "spaces in path/Main.daml" damlId $ T.unlines - [ "daml 1.2" - , "module Main where" + [ "module Main where" , "main = scenario $ pure \"ok\"" ] scenario <- openScenario "spaces in path/Main.daml" "main" @@ -580,8 +553,7 @@ executeCommandTests :: (forall a. Session a -> IO a) -> (Session () -> IO ()) -> executeCommandTests run _ = testGroup "execute command" [ testCase "execute commands" $ run $ do main' <- openDoc' "Coin.daml" damlId $ T.unlines - [ "daml 1.2" - , "module Coin where" + [ "module Coin where" , "template Coin" , " with" , " owner : Party" @@ -599,8 +571,7 @@ executeCommandTests run _ = testGroup "execute command" closeDoc main' , testCase "Invalid commands result in error" $ run $ do main' <- openDoc' "Empty.daml" damlId $ T.unlines - [ "daml 1.2" - , "module Empty where" + [ "module Empty where" ] Just escapedFp <- pure $ uriToFilePath (main' ^. uri) actualDotString :: ExecuteCommandResponse <- LSP.request WorkspaceExecuteCommand $ ExecuteCommandParams @@ -629,8 +600,7 @@ stressTests run _runScenarios = testGroup "Stress tests" fooValue i = T.pack (show (i `div` 2)) <> if even i then "" else ".5" fooContent i = T.unlines - [ "daml 1.2" - , "module Foo where" + [ "module Foo where" , "foo : Int" , "foo = " <> fooValue i ] @@ -664,7 +634,7 @@ stressTests run _runScenarios = testGroup "Stress tests" foos <- forM [1 .. 10 :: Int] $ \i -> makeModule ("Foo" ++ show i) ["foo 10"] expectDiagnostics - [ ("Foo" ++ show i ++ ".daml", [(DsError, (2, 0), "Parse error")]) + [ ("Foo" ++ show i ++ ".daml", [(DsError, (1, 0), "Parse error")]) | i <- [1 .. 10 :: Int] ] forM_ (zip [1 .. 10 :: Int] foos) $ \(i, foo) -> @@ -695,7 +665,7 @@ stressTests run _runScenarios = testGroup "Stress tests" , "foo0 = foo1" ] withTimeout 90 $ do - expectDiagnostics [("Foo0.daml", [(DsError, (4, 7), "Couldn't match expected type")])] + expectDiagnostics [("Foo0.daml", [(DsError, (3, 7), "Couldn't match expected type")])] void $ replaceDoc foo0 $ moduleContent "Foo0" [ "import Foo1" , "foo0 : Bool" @@ -707,8 +677,7 @@ stressTests run _runScenarios = testGroup "Stress tests" where moduleContent :: String -> [T.Text] -> T.Text moduleContent name lines = T.unlines $ - [ "daml 1.2" - , "module " <> T.pack name <> " where" + [ "module " <> T.pack name <> " where" ] ++ lines makeModule :: String -> [T.Text] -> Session TextDocumentIdentifier makeModule name lines = openDoc' (name ++ ".daml") damlId $ @@ -724,20 +693,19 @@ regressionTests run _runScenarios = testGroup "regression" -- since we used a function from GHCi in ghcide. foo <- openDoc' "Foo.daml" damlId $ T.unlines [ "{-# OPTIONS_GHC -Wall #-}" - , "daml 1.2" , "module Foo where" , "import DA.List" , "" ] - expectDiagnostics [("Foo.daml", [(DsWarning, (3,0), "redundant")])] - completions <- getCompletions foo (Position 3 1) + expectDiagnostics [("Foo.daml", [(DsWarning, (2,0), "redundant")])] + completions <- getCompletions foo (Position 2 1) liftIO $ assertBool ("DA.List and DA.Internal.RebindableSyntax should be in " <> show completions) $ mkModuleCompletion "DA.Internal.RebindableSyntax" `elem` completions && mkModuleCompletion "DA.List" `elem` completions - changeDoc foo [TextDocumentContentChangeEvent (Just (Range (Position 3 0) (Position 3 1))) Nothing "Syntax"] - expectDiagnostics [("Foo.daml", [(DsError, (3,0), "Parse error")])] - completions <- getCompletions foo (Position 3 6) + changeDoc foo [TextDocumentContentChangeEvent (Just (Range (Position 2 0) (Position 2 1))) Nothing "Syntax"] + expectDiagnostics [("Foo.daml", [(DsError, (2,0), "Parse error")])] + completions <- getCompletions foo (Position 2 6) liftIO $ completions @?= [mkModuleCompletion "DA.Internal.RebindableSyntax" & detail .~ Nothing] ] @@ -882,7 +850,7 @@ multiPackageTests damlc , "dependencies: [daml-prim, daml-stdlib]" ] writeFileUTF8 (dir "a" "A.daml") $ unlines - [ "daml 1.2 module A where" + [ "module A where" , "data A = A" , "a = A" ] @@ -897,7 +865,7 @@ multiPackageTests damlc , "dependencies: [daml-prim, daml-stdlib, " <> show (".." "a" "a.dar") <> "]" ] writeFileUTF8 (dir "b" "B.daml") $ unlines - [ "daml 1.2 module B where" + [ "module B where" , "import A" , "f : Scenario A" , "f = pure a" @@ -951,7 +919,7 @@ multiPackageTests damlc , "dependencies: [daml-prim, daml-stdlib]" ] writeFileUTF8 (dir "a" "A.daml") $ unlines - [ "daml 1.2 module A where" + [ "module A where" , "data A = A" , "a = A" ] @@ -966,7 +934,7 @@ multiPackageTests damlc , "dependencies: [daml-prim, daml-stdlib, " <> show (".." "a" "a.dar") <> "]" ] writeFileUTF8 (dir "b" "B.daml") $ unlines - [ "daml 1.2 module B where" + [ "module B where" , "import A" , "f : Scenario A" , "f = pure a" diff --git a/daml-assistant/daml-helper/test/DA/Daml/Helper/Test/Deployment.hs b/daml-assistant/daml-helper/test/DA/Daml/Helper/Test/Deployment.hs index 61033d6689d..b5ed3c31e39 100644 --- a/daml-assistant/daml-helper/test/DA/Daml/Helper/Test/Deployment.hs +++ b/daml-assistant/daml-helper/test/DA/Daml/Helper/Test/Deployment.hs @@ -167,7 +167,6 @@ writeMinimalProject = do , " - daml-stdlib" ] writeFileUTF8 "Main.daml" $ unlines - [ "daml 1.2" - , "module Main where" + [ "module Main where" , "template T with p : Party where signatory p" ] diff --git a/daml-assistant/integration-tests/src/DA/Daml/Assistant/IntegrationTests.hs b/daml-assistant/integration-tests/src/DA/Daml/Assistant/IntegrationTests.hs index 8d09ea3e54a..1a3886233be 100644 --- a/daml-assistant/integration-tests/src/DA/Daml/Assistant/IntegrationTests.hs +++ b/daml-assistant/integration-tests/src/DA/Daml/Assistant/IntegrationTests.hs @@ -105,8 +105,7 @@ packagingTests = testGroup "packaging" , " - daml-stdlib" ] writeFileUTF8 (myDepDir "daml" "MyDep.daml") $ unlines - [ "daml 1.2" - , "module MyDep where" + [ "module MyDep where" ] withCurrentDirectory myDepDir $ callCommandSilent "daml build -o mydep.dar" let myTriggerDir = tmpDir "mytrigger" @@ -123,8 +122,7 @@ packagingTests = testGroup "packaging" , " - " <> myDepDir "mydep.dar" ] writeFileUTF8 (myTriggerDir "daml/Main.daml") $ unlines - [ "daml 1.2" - , "module Main where" + [ "module Main where" , "import MyDep ()" , "import Daml.Trigger ()" ] @@ -216,8 +214,7 @@ packagingTests = testGroup "packaging" , " - --wall-clock-time" ] writeFileUTF8 (projDir "daml/Main.daml") $ unlines - [ "daml 1.2" - , "module Main where" + [ "module Main where" , "import Daml.Script" , "template T with p : Party where signatory p" , "init : Script ()" @@ -283,8 +280,7 @@ packagingTests = testGroup "packaging" , " - daml-stdlib" ] writeFileUTF8 (projDir "daml/Main.daml") $ unlines - [ "daml 1.2" - , "module Main where" + [ "module Main where" , "template T with p : Party where signatory p" ] sandboxPort :: Int <- fromIntegral <$> getFreePort @@ -379,8 +375,7 @@ packagingTests = testGroup "packaging" , " - daml-stdlib" ] writeFileUTF8 (projDir "daml/Main.daml") $ unlines - [ "daml 1.2" - , "module Main where" + [ "module Main where" , "template T with p : Party where signatory p" ] sandboxPort :: Int <- fromIntegral <$> getFreePort diff --git a/daml-lf/interpreter/perf/daml/Examples.daml b/daml-lf/interpreter/perf/daml/Examples.daml index c4af2729fb1..3544fc2be0d 100644 --- a/daml-lf/interpreter/perf/daml/Examples.daml +++ b/daml-lf/interpreter/perf/daml/Examples.daml @@ -1,8 +1,6 @@ -- Copyright (c) 2020 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -- SPDX-License-Identifier: Apache-2.0 -daml 1.2 - module Examples where nfib 0 = 1 diff --git a/daml-lf/tests/scenario/stable/contract-key-through-exercises/Test.daml b/daml-lf/tests/scenario/stable/contract-key-through-exercises/Test.daml index 573b11e00cc..addb0ed420b 100644 --- a/daml-lf/tests/scenario/stable/contract-key-through-exercises/Test.daml +++ b/daml-lf/tests/scenario/stable/contract-key-through-exercises/Test.daml @@ -1,7 +1,7 @@ -- Copyright (c) 2020 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -- SPDX-License-Identifier: Apache-2.0 -daml 1.2 module Test where +module Test where import qualified DA.Next.Set as S import DA.Next.Set (Set) @@ -62,4 +62,3 @@ run = scenario do _ <- submitMustFail bob $ exercise accepted LookupGivenKey with actor = bob, keyMaintainers = salice pure () - diff --git a/docs/source/daml/reference/file-structure.rst b/docs/source/daml/reference/file-structure.rst index 2db36006632..ff6ddbc59ec 100644 --- a/docs/source/daml/reference/file-structure.rst +++ b/docs/source/daml/reference/file-structure.rst @@ -11,7 +11,6 @@ This page gives reference information on the structure of DAML files outside of File structure ************** -- Language version (``daml 1.2``). - This file's module name (``module NameOfThisFile where``). Part of a hierarchical module system to facilitate code reuse. Must be the same as the DAML file name, without the file extension. diff --git a/docs/source/tools/extractor.rst b/docs/source/tools/extractor.rst index 930f084c20c..9e1b69d78dc 100644 --- a/docs/source/tools/extractor.rst +++ b/docs/source/tools/extractor.rst @@ -40,7 +40,7 @@ $ daml extractor --help Trying it out ************* -This example extracts: +This example extracts: - all contract data from the beginning of the ledger to the current latest transaction - for the party ``Scrooge_McDuck`` @@ -53,7 +53,7 @@ This example extracts: $ daml extractor postgresql --user postgres --connecturl jdbc:postgresql:daml_export --party Scrooge_McDuck -h 192.168.1.12 -p 6865 --to head -This terminates after reaching the transaction which was the latest at the time the Extractor started streaming. +This terminates after reaching the transaction which was the latest at the time the Extractor started streaming. To run the Extractor indefinitely, and thus keeping the database up to date as new transactions arrive on the ledger, omit the ``--to head`` parameter to fall back to the default streaming-indefinitely approach, or state explicitly by using the ``--to follow`` parameter. @@ -299,8 +299,8 @@ When updating packages, you can end up with multiple versions of the same packag Let’s say you have a template called ``My.Company.Finance.Account``:: - daml 1.2 module My.Company.Finance.Account where - + module My.Company.Finance.Account where + template Account with provider: Party @@ -314,8 +314,8 @@ This is built into a package with a resulting hash ``6021727fe0822d688ddd5459974 Later you add a new field, ``displayName``:: - daml 1.2 module My.Company.Finance.Account where - + module My.Company.Finance.Account where + template Account with provider: Party @@ -330,22 +330,22 @@ The hash of the new package with the update is ``1239d1c5df140425f01a5112325d2e4 There are contract instances of first version of the template which were created before the new field is added, and there are contract instances of the new version which were created since. Let’s say you have one instance of each:: - { + { "owner":"Bob", "provider":"Bob", "accountId":"6021-5678", - "observers":[ + "observers":[ "Alice" ] } and:: - { + { "owner":"Bob", "provider":"Bob", "accountId":"1239-4321", - "observers":[ + "observers":[ "Alice" ], "displayName":"Personal" @@ -359,7 +359,7 @@ They will look like this when extracted: To have a consistent view of the two versions with a default value ``NULL`` for the missing field of instances of older versions, you can create a view which contains all ``Account`` rows:: CREATE VIEW account_view AS - SELECT + SELECT create_arguments->>'owner' AS owner ,create_arguments->>'provider' AS provider ,create_arguments->>'accountId' AS accountId @@ -372,7 +372,7 @@ To have a consistent view of the two versions with a default value ``NULL`` for AND template = 'My.Company.Finance.Account' UNION - SELECT + SELECT create_arguments->>'owner' AS owner ,create_arguments->>'provider' AS provider ,create_arguments->>'accountId' AS accountId @@ -393,14 +393,14 @@ Then, ``account_view will`` contain both contract instances: Logging ******* -By default, the Extractor logs to stderr, with INFO verbose level. To change the level, use the ``-DLOGLEVEL=[level]`` option, e.g. ``-DLOGLEVEL=TRACE``. +By default, the Extractor logs to stderr, with INFO verbose level. To change the level, use the ``-DLOGLEVEL=[level]`` option, e.g. ``-DLOGLEVEL=TRACE``. You can supply your own logback configuration file via the standard method: https://logback.qos.ch/manual/configuration.html Continuity ********** -When you terminate the Extractor and restart it, it will continue from where it left off. This happens because, when running, it saves its state into the ``state`` table in the ``public`` schema of the database. When started, it reads the contents of this table. If there’s a saved state from a previous run, it restarts from where it left off. There’s no need to explicitly specify anything, this is done automatically. +When you terminate the Extractor and restart it, it will continue from where it left off. This happens because, when running, it saves its state into the ``state`` table in the ``public`` schema of the database. When started, it reads the contents of this table. If there’s a saved state from a previous run, it restarts from where it left off. There’s no need to explicitly specify anything, this is done automatically. DO NOT modify content of the ``state`` table. Doing so can result in the Extractor not being able to continue running against the database. If that happens, you must delete all data from the database and start again. @@ -411,7 +411,7 @@ The only parameters that you can change between two sessions running against the Fault tolerance *************** -Once the Extractor connects to the Ledger Node and the database and creates the table structure from the fetched DAML packages, it wraps the transaction stream in a restart logic with an exponential backoff. This results in the Extractor not terminating even when the transaction stream is aborted for some reason (the ledger node is down, there’s a network partition, etc.). +Once the Extractor connects to the Ledger Node and the database and creates the table structure from the fetched DAML packages, it wraps the transaction stream in a restart logic with an exponential backoff. This results in the Extractor not terminating even when the transaction stream is aborted for some reason (the ledger node is down, there’s a network partition, etc.). Once the connection is back, it continues the stream from where it left off. If it can’t reach the node on the host/port pair the Extractor was started with, you need to manually stop it and restart with the updated address. @@ -422,7 +422,7 @@ Troubleshooting Can’t connect to the Ledger Node ================================ - + If the Extractor can’t connect to the Ledger node on startup, you’ll see a message like this in the logs, and the Extractor will terminate:: 16:47:51.208 ERROR c.d.e.Main$@[akka.actor.default-dispatcher-7] - FAILURE: diff --git a/extractor/BUILD.bazel b/extractor/BUILD.bazel index 9ce441b5b7d..6d64e1187ee 100644 --- a/extractor/BUILD.bazel +++ b/extractor/BUILD.bazel @@ -45,11 +45,11 @@ genrule( filecount=32 outs=($(OUTS)) main="$${outs[0]}" - echo 'daml 1.2 + echo ' module VeryLargeArchive.Blobs where import VeryLargeArchive.Blob1()' > "$$main" firstfil="$${outs[1]}" - echo 'daml 1.2 + echo ' module VeryLargeArchive.Blob1 where ' > "$$firstfil" { for linen in `seq 1 1024`; do diff --git a/ledger/test-common/src/main/daml/performance/PingPong.daml b/ledger/test-common/src/main/daml/performance/PingPong.daml index 9fce6cbd903..a4040ad9a5b 100644 --- a/ledger/test-common/src/main/daml/performance/PingPong.daml +++ b/ledger/test-common/src/main/daml/performance/PingPong.daml @@ -1,7 +1,6 @@ -- Copyright (c) 2020 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. -- SPDX-License-Identifier: Apache-2.0 -daml 1.2 module PingPong where template Ping