Skip to content

Commit

Permalink
Update error message & expected error message
Browse files Browse the repository at this point in the history
  • Loading branch information
dylant-da committed Jul 9, 2024
1 parent e78ef35 commit 1ec643d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
12 changes: 8 additions & 4 deletions sdk/compiler/daml-lf-tools/src/DA/Daml/LF/TypeChecker/Error.hs
Original file line number Diff line number Diff line change
Expand Up @@ -214,20 +214,24 @@ instance Pretty WarnableError where
pPrint = \case
WEUpgradeShouldDefineIfacesAndTemplatesSeparately ->
vsep
[ "This package defines both interfaces and templates."
, "This is not recommended - templates are upgradeable, but interfaces are not, which means that this version of the package and its templates can never be uninstalled."
[ "This package defines both interfaces and templates. This may make this package and its dependents not upgradeable."
, "It is recommended that interfaces are defined in their own package separate from their implementations."
, "Ignore this error message with the --warn-bad-interface-instances=yes flag."
]
WEUpgradeShouldDefineIfaceWithoutImplementation iface implementingTemplates ->
vsep $ concat
[ [ "The interface " <> pPrint iface <> " was defined in this package and implemented in this package by the following templates:" ]
, map (quotes . pPrint) implementingTemplates
, [ "However, it is recommended that interfaces are defined in their own package separate from their implementations." ]
, [ "This may make this package and its dependents not upgradeable." ]
, [ "It is recommended that interfaces are defined in their own package separate from their implementations." ]
, [ "Ignore this error message with the --warn-bad-interface-instances=yes flag." ]
]
WEUpgradeShouldDefineTplInSeparatePackage tpl iface ->
vsep
[ "The template " <> pPrint tpl <> " has implemented interface " <> pPrint iface <> ", which is defined in a previous version of this package."
, "However, it is recommended that interfaces are defined in their own package separate from their implementations."
, "This may make this package and its dependents not upgradeable."
, "It is recommended that interfaces are defined in their own package separate from their implementations."
, "Ignore this error message with the --warn-bad-interface-instances=yes flag."
]

data UpgradedRecordOrigin
Expand Down
5 changes: 3 additions & 2 deletions sdk/compiler/damlc/tests/src/DA/Test/DamlcUpgrades.hs
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ tests damlc =
[ testGeneral
(prefix <> "WhenAnInterfaceAndATemplateAreDefinedInTheSamePackage")
"WarnsWhenAnInterfaceAndATemplateAreDefinedInTheSamePackage"
(expectation "type checking module Main:\n This package defines both interfaces and templates.\n \n This is not recommended - templates are upgradeable, but interfaces are not, which means that this version of the package and its templates can never be uninstalled.\n \n It is recommended that interfaces are defined in their own package separate from their implementations.")
(expectation "type checking module Main:\n This package defines both interfaces and templates.")
LF.versionDefault
NoDependencies
warnBadInterfaceInstances
Expand All @@ -417,7 +417,7 @@ tests damlc =
, testGeneral
(prefix <> "WhenAnInterfaceIsUsedInThePackageThatItsDefinedIn")
"WarnsWhenAnInterfaceIsUsedInThePackageThatItsDefinedIn"
(expectation "type checking interface Main.I :\n The interface I was defined in this package and implemented in this package by the following templates:\n \n 'T'\n \n However, it is recommended that interfaces are defined in their own package separate from their implementations.")
(expectation "type checking interface Main.I :\n The interface I was defined in this package and implemented in this package by the following templates:")
LF.versionDefault
NoDependencies
warnBadInterfaceInstances
Expand Down Expand Up @@ -473,6 +473,7 @@ tests damlc =
testGeneral name location expectation lfVersion sharedDep warnBadInterfaceInstances setUpgradeField doTypecheck =
let upgradeFieldTrailer = if not setUpgradeField then " (no upgrades field)" else ""
doTypecheckTrailer = if not doTypecheck then " (disable typechecking)" else ""
in
testCase (name <> upgradeFieldTrailer <> doTypecheckTrailer) $
withTempDir $ \dir -> do
let newDir = dir </> "newVersion"
Expand Down

0 comments on commit 1ec643d

Please sign in to comment.