Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade validation warnings to errors flag #19259

Merged
merged 11 commits into from
Jul 10, 2024
Prev Previous commit
Update error message & expected error message
  • Loading branch information
dylant-da committed Jul 9, 2024
commit 1ec643d9a8bfb6e86ee1add9ea124b72bac3f84b
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