mirror of
https://github.com/digital-asset/daml.git
synced 2024-09-19 16:57:40 +03:00
Remove compiler support for controller..can
choice syntax (#17362)
* Update GHC_REV * Remove 'controller..can' syntax in java codegen StakeholdersTest * Remove 'controller..can' syntax in ChoiceSyntaxes daml-test-file * Remove daml-test-files {,No}WarnControllerCan * Remove 'controller..can' syntax in SemanticsEvalOrder{,RightToLeft} daml-test-files * Update {Structure,Reference}.daml code snippets for docs.daml.com * Remove 'controller..can' syntax in TestGrammar.daml * changelog entry for 'controller..can' removal * Update UNRELEASED.md Co-authored-by: carrielaben-da <91496516+carrielaben-da@users.noreply.github.com>
This commit is contained in:
parent
74d7459ceb
commit
1bee52e40c
@ -60,6 +60,19 @@ following warning will be shown during compilation or in the IDE:
|
||||
|
||||
For more information, see [Reference: Templates: Template-local Definitions (Deprecated)](https://docs.daml.com/2.8.0/daml/reference/templates.html#template-local-definitions-deprecated)
|
||||
|
||||
## Removal of deprecated 'controller..can' syntax
|
||||
|
||||
The 'controller..can' syntax for defining template choices, deprecated since
|
||||
Daml 2.0, has now been completely removed. Projects that use this syntax are no
|
||||
longer accepted. Those choices should instead be defined using 'choice-first'
|
||||
syntax.
|
||||
|
||||
Note that, as a consequence, the warning flags `-Wcontroller-can` and
|
||||
`-Wnocontroller-can` are not accepted anymore.
|
||||
|
||||
See [Deprecation of `controller`-first syntax: Migrating](https://docs.daml.com/2.7.0/daml/reference/choices.html#migrating)
|
||||
for more information on how to adapt existing projects.
|
||||
|
||||
## What’s New
|
||||
### Daml-script json support for --all
|
||||
The daml-script binary runner has been refactored to be more consistent across using `--script-name` and `--all`.
|
||||
|
@ -9,7 +9,7 @@ GHC_LIB_PATCHES = [
|
||||
]
|
||||
|
||||
GHC_REPO_URL = "https://github.com/digital-asset/ghc"
|
||||
GHC_REV = "760149aceaf1c870b122308e8af792c1c4546091"
|
||||
GHC_REV = "6cea01bd8eec50722bffa9b3b1b9067653ee6123"
|
||||
GHC_PATCHES = [
|
||||
]
|
||||
|
||||
|
@ -29,14 +29,3 @@ template FeatureSuggestion
|
||||
do
|
||||
assert $ elem sponsor founders -- assert -> source.daml
|
||||
create FeatureAssignment with employee, description, sponsor -- create -> source.daml
|
||||
|
||||
-- deprecated syntax: 'controller ... can' will be removed in a future version of Daml.
|
||||
controller employee can
|
||||
nonconsuming DoNothing : ()
|
||||
do
|
||||
return ()
|
||||
|
||||
-- deprecated syntax: 'controller ... can' will be removed in a future version of Daml.
|
||||
controller employee can
|
||||
Revoke : ()
|
||||
do pure ()
|
||||
|
@ -3,8 +3,6 @@
|
||||
|
||||
-- Check that all syntaxes for defining choices can be parsed.
|
||||
|
||||
{-# OPTIONS_GHC -Wno-controller-can #-}
|
||||
|
||||
module ChoiceSyntaxes where
|
||||
|
||||
template T with
|
||||
@ -22,15 +20,3 @@ template T with
|
||||
controller p
|
||||
do
|
||||
pure ()
|
||||
|
||||
-- deprecated syntax: 'controller ... can' will be removed in a future version of Daml.
|
||||
-- This file tests the various options for defining choices, so we keep it until it is removed.
|
||||
controller p can
|
||||
C3 : () with
|
||||
x : ()
|
||||
do
|
||||
pure ()
|
||||
|
||||
C4 : ()
|
||||
do
|
||||
pure ()
|
||||
|
@ -1,17 +0,0 @@
|
||||
-- Copyright (c) 2021, Digital Asset (Switzerland) GmbH and/or its affiliates.
|
||||
-- All rights reserved.
|
||||
|
||||
{-# OPTIONS_GHC -Wno-controller-can #-}
|
||||
|
||||
module NoWarnControllerCan where
|
||||
|
||||
template T with
|
||||
p : Party
|
||||
q : Party
|
||||
where
|
||||
signatory p
|
||||
|
||||
controller q can
|
||||
nonconsuming Pass : ()
|
||||
do
|
||||
pure ()
|
@ -10,7 +10,6 @@
|
||||
-- the same rule, we use `R_1`, `R_2`, `R_3`, and so on. This is why there is
|
||||
-- `evExpRecUpdErr1`, `evExpRecUpdErr2_1`, and `evExpRecUpdErr2_2`, for example.)
|
||||
|
||||
{-# OPTIONS_GHC -Wno-controller-can #-}
|
||||
{-# LANGUAGE ApplicativeDo #-}
|
||||
|
||||
module SemanticsEvalOrder where
|
||||
@ -246,7 +245,7 @@ evUpdCreateErr1 = script do
|
||||
createCmd (T_EvUpdCreateErr1 p)
|
||||
abort "EvUpdCreateErr1 failed (4)"
|
||||
|
||||
-- @ERROR range=260:1-260:16; Template precondition violated
|
||||
-- @ERROR range=259:1-259:16; Template precondition violated
|
||||
template T_EvUpdCreateFail
|
||||
with
|
||||
p : Party
|
||||
@ -371,29 +370,6 @@ evUpdCreateWithKeyErr2 = script do
|
||||
createCmd (T_EvUpdCreateWithKeyErr2 p)
|
||||
abort "EvUpdCreateWithKeyErr2 failed"
|
||||
|
||||
-- | `controller P can ...` syntax adds `P` to the observers,
|
||||
-- so if `P` causes an error, this is triggered on create,
|
||||
-- instead of on exercise.
|
||||
-- @ERROR controllerCanAddsObserver OK
|
||||
template T_ControllerCanAddsObserver
|
||||
with
|
||||
p : Party
|
||||
where
|
||||
signatory p
|
||||
-- deprecated syntax: 'controller ... can' will be removed in a future version of Daml.
|
||||
-- This tests that `controller X can` implicitly adds `X` as an observer, so we keep
|
||||
-- it until it is removed.
|
||||
controller (error @Party "controllerCanAddsObserver OK") can
|
||||
C_ControllerCanAddsObserver: ()
|
||||
do pure ()
|
||||
|
||||
controllerCanAddsObserver : Script ()
|
||||
controllerCanAddsObserver = script do
|
||||
p <- allocateParty "Alice"
|
||||
submit p do
|
||||
createCmd (T_ControllerCanAddsObserver p)
|
||||
abort "controllerCanAddsObserver failed"
|
||||
|
||||
-- | `choice ... controller P ...` doesn't add `P` as observer.
|
||||
-- This test is here to contrast with the previous.
|
||||
-- @ERROR choiceControllerDoesntAddObserver OK
|
||||
|
@ -10,7 +10,6 @@
|
||||
-- the same rule, we use `R_1`, `R_2`, `R_3`, and so on. This is why there is
|
||||
-- `evExpRecUpdErr1`, `evExpRecUpdErr2_1`, and `evExpRecUpdErr2_2`, for example.)
|
||||
|
||||
{-# OPTIONS_GHC -Wno-controller-can #-}
|
||||
{-# LANGUAGE ApplicativeDo #-}
|
||||
|
||||
module SemanticsEvalOrderRightToLeft where
|
||||
@ -246,7 +245,7 @@ evUpdCreateErr1 = script do
|
||||
createCmd (T_EvUpdCreateErr1 p)
|
||||
abort "EvUpdCreateErr1 failed (4)"
|
||||
|
||||
-- @ERROR range=260:1-260:16; Template precondition violated
|
||||
-- @ERROR range=259:1-259:16; Template precondition violated
|
||||
template T_EvUpdCreateFail
|
||||
with
|
||||
p : Party
|
||||
@ -371,29 +370,6 @@ evUpdCreateWithKeyErr2 = script do
|
||||
createCmd (T_EvUpdCreateWithKeyErr2 p)
|
||||
abort "EvUpdCreateWithKeyErr2 failed"
|
||||
|
||||
-- | `controller P can ...` syntax adds `P` to the observers,
|
||||
-- so if `P` causes an error, this is triggered on create,
|
||||
-- instead of on exercise.
|
||||
-- @ERROR controllerCanAddsObserver OK
|
||||
template T_ControllerCanAddsObserver
|
||||
with
|
||||
p : Party
|
||||
where
|
||||
signatory p
|
||||
-- deprecated syntax: 'controller ... can' will be removed in a future version of Daml.
|
||||
-- This tests that `controller X can` implicitly adds `X` as an observer, so we keep
|
||||
-- it until it is removed.
|
||||
controller (error @Party "controllerCanAddsObserver OK") can
|
||||
C_ControllerCanAddsObserver: ()
|
||||
do pure ()
|
||||
|
||||
controllerCanAddsObserver : Script ()
|
||||
controllerCanAddsObserver = script do
|
||||
p <- allocateParty "Alice"
|
||||
submit p do
|
||||
createCmd (T_ControllerCanAddsObserver p)
|
||||
abort "controllerCanAddsObserver failed"
|
||||
|
||||
-- | `choice ... controller P ...` doesn't add `P` as observer.
|
||||
-- This test is here to contrast with the previous.
|
||||
-- @ERROR choiceControllerDoesntAddObserver OK
|
||||
|
@ -1,17 +0,0 @@
|
||||
-- Copyright (c) 2021, Digital Asset (Switzerland) GmbH and/or its affiliates.
|
||||
-- All rights reserved.
|
||||
|
||||
-- @WARN range=14:5-17:18; The syntax 'controller ... can' is deprecated
|
||||
|
||||
module WarnControllerCan where
|
||||
|
||||
template T with
|
||||
p : Party
|
||||
q : Party
|
||||
where
|
||||
signatory p
|
||||
|
||||
controller q can
|
||||
nonconsuming Pass : ()
|
||||
do
|
||||
pure ()
|
@ -1,8 +1,6 @@
|
||||
-- Copyright (c) 2023 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
|
||||
-- SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
{-# OPTIONS -Wno-controller-can #-}
|
||||
|
||||
-- template-let warning disabled because 'start template let snippet' is
|
||||
-- used by docs.daml.com for older compiler versions and to explain
|
||||
-- new deprecation warning in 2.8.0
|
||||
@ -50,6 +48,63 @@ template NameOfTemplate
|
||||
key (exampleParty, exampleParam) : (Party, Text)
|
||||
maintainer (exampleFunction key)
|
||||
-- end contract key snippet
|
||||
|
||||
-- start new template choice snippet
|
||||
choice NameOfChoice
|
||||
: () -- replace () with the actual return type
|
||||
with
|
||||
exampleParameter : Text -- parameters here
|
||||
controller exampleParty
|
||||
do
|
||||
return () -- replace this line with the choice body
|
||||
-- end new template choice snippet
|
||||
|
||||
-- start new choice name snippet
|
||||
choice ExampleChoice
|
||||
: () -- replace () with the actual return type
|
||||
-- end new choice name snippet
|
||||
-- start new choice params snippet
|
||||
with
|
||||
exampleParameter : Text
|
||||
-- end new choice params snippet
|
||||
-- start new controller snippet
|
||||
controller exampleParty
|
||||
-- end new controller snippet
|
||||
do
|
||||
return () -- replace () with the actual return type
|
||||
-- start new preconsuming snippet
|
||||
preconsuming choice ExamplePreconsumingChoice
|
||||
: () -- replace () with the actual return type
|
||||
-- end new preconsuming snippet
|
||||
with -- params
|
||||
controller exampleParty
|
||||
do
|
||||
return ()
|
||||
-- start new postconsuming snippet
|
||||
postconsuming choice ExamplePostconsumingChoice
|
||||
: () -- replace () with the actual return type
|
||||
-- end new postconsuming snippet
|
||||
with -- params
|
||||
controller exampleParty
|
||||
do
|
||||
return ()
|
||||
-- start new nonconsuming snippet
|
||||
nonconsuming choice ExampleNonconsumingChoice
|
||||
: () -- replace () with the actual return type
|
||||
-- end new nonconsuming snippet
|
||||
with -- params
|
||||
controller exampleParty
|
||||
do
|
||||
return ()
|
||||
|
||||
{- LEGACY CHOICE SNIPPETS
|
||||
Before Daml 2.8.0, two syntaxes were supported for declaring choices,
|
||||
choice name first and controller-first. The latter was removed, so the
|
||||
code below doesn't compile anymore, but docs.daml.com uses the version
|
||||
of this file in the `main` branch, including when building the docs
|
||||
for Daml <2.8.0, so it's easier to leave the old snippets alone for
|
||||
those versions.
|
||||
|
||||
-- start template choice snippet
|
||||
-- option 1 for specifying choices: choice name first
|
||||
choice NameOfChoice1
|
||||
@ -147,3 +202,4 @@ template NameOfTemplate
|
||||
-- end controller-first nonconsuming snippet
|
||||
do
|
||||
return () -- replace () with the actual return type
|
||||
-}
|
||||
|
@ -1,7 +1,6 @@
|
||||
-- Copyright (c) 2023 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
|
||||
-- SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
{-# OPTIONS -Wno-controller-can #-}
|
||||
module Structure where
|
||||
|
||||
exampleFunction : (Party, Text) -> Party
|
||||
@ -28,6 +27,36 @@ template NameOfTemplate
|
||||
maintainer (exampleFunction key)
|
||||
-- a choice goes here; see next section
|
||||
-- end of template outline snippet
|
||||
|
||||
-- start of new choice snippet
|
||||
choice NameOfChoice
|
||||
: () -- replace () with the actual return type
|
||||
with
|
||||
party : Party -- parameters here
|
||||
controller party
|
||||
do
|
||||
return () -- replace this line with the choice body
|
||||
-- end of new choice snippet
|
||||
|
||||
-- start of new choice observer snippet
|
||||
choice NameOfChoiceWithObserver
|
||||
: () -- replace () with the actual return type
|
||||
with
|
||||
party : Party -- parameters here
|
||||
observer party -- optional specification of choice observers
|
||||
controller exampleParty
|
||||
do
|
||||
return () -- replace this line with the choice body
|
||||
-- end of new choice observer snippet
|
||||
|
||||
{- LEGACY CHOICE SNIPPETS
|
||||
Before Daml 2.8.0, two syntaxes were supported for declaring choices,
|
||||
choice name first and controller-first. The latter was removed, so the
|
||||
code below doesn't compile anymore, but docs.daml.com uses the version
|
||||
of this file in the `main` branch, including when building the docs
|
||||
for Daml <2.8.0, so it's easier to leave the old snippets alone for
|
||||
those versions.
|
||||
|
||||
-- start of choice snippet
|
||||
-- option 1 for specifying choices: choice name first
|
||||
choice NameOfChoice
|
||||
@ -46,7 +75,7 @@ template NameOfTemplate
|
||||
party : Party -- parameters here
|
||||
do
|
||||
return () -- replace the line with the choice body
|
||||
-- end of choice snippet
|
||||
-- end of choice snippet
|
||||
|
||||
-- start of choice observer snippet
|
||||
-- choice observers may be specified if option 1 is used
|
||||
@ -59,3 +88,4 @@ template NameOfTemplate
|
||||
do
|
||||
return () -- replace this line with the choice body
|
||||
-- end of choice observer snippet
|
||||
-}
|
||||
|
@ -1,6 +1,5 @@
|
||||
-- Copyright (c) 2023 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
|
||||
-- SPDX-License-Identifier: Apache-2.0
|
||||
{-# OPTIONS -Wno-controller-can #-}
|
||||
|
||||
module Stakeholders where
|
||||
|
||||
@ -10,25 +9,6 @@ template OnlySignatories
|
||||
where
|
||||
signatory owner
|
||||
|
||||
-- deprecated syntax: 'controller ... can' will be removed in a future version of Daml.
|
||||
-- This file tests the various options for defining choices, so we keep it until it is removed.
|
||||
controller owner can
|
||||
OnlySignatories_Choice : ()
|
||||
do return ()
|
||||
|
||||
template ImplicitObservers
|
||||
with
|
||||
owner: Party
|
||||
thirdParty: Party
|
||||
where
|
||||
signatory owner
|
||||
|
||||
-- deprecated syntax: 'controller ... can' will be removed in a future version of Daml.
|
||||
-- This file tests the various options for defining choices, so we keep it until it is removed.
|
||||
controller thirdParty can
|
||||
ImplicitObservers_Choice : ()
|
||||
do return ()
|
||||
|
||||
template ExplicitObservers
|
||||
with
|
||||
owner: Party
|
||||
@ -36,24 +16,3 @@ template ExplicitObservers
|
||||
where
|
||||
signatory owner
|
||||
observer thirdParty
|
||||
|
||||
-- deprecated syntax: 'controller ... can' will be removed in a future version of Daml.
|
||||
-- This file tests the various options for defining choices, so we keep it until it is removed.
|
||||
controller owner can
|
||||
ExplicitObservers_Choice : ()
|
||||
do return ()
|
||||
|
||||
template MixedObservers
|
||||
with
|
||||
owner: Party
|
||||
thirdParty1: Party
|
||||
thirdParty2: Party
|
||||
where
|
||||
signatory owner
|
||||
observer thirdParty1
|
||||
|
||||
-- deprecated syntax: 'controller ... can' will be removed in a future version of Daml.
|
||||
-- This file tests the various options for defining choices, so we keep it until it is removed.
|
||||
controller thirdParty2 can
|
||||
MixedObservers_Choice : ()
|
||||
do return ()
|
||||
|
@ -9,7 +9,7 @@ import io.grpc.Channel
|
||||
import org.scalatest.Assertion
|
||||
import org.scalatest.flatspec.AsyncFlatSpecLike
|
||||
import org.scalatest.matchers.should.Matchers
|
||||
import stakeholders.{ExplicitObservers, ImplicitObservers, MixedObservers, OnlySignatories}
|
||||
import stakeholders.{ExplicitObservers, OnlySignatories}
|
||||
|
||||
import scala.concurrent.Future
|
||||
|
||||
@ -26,20 +26,16 @@ trait StakeholdersTest
|
||||
testCode: (
|
||||
String,
|
||||
OnlySignatories,
|
||||
ImplicitObservers,
|
||||
ExplicitObservers,
|
||||
MixedObservers,
|
||||
Channel,
|
||||
) => Assertion
|
||||
): Future[Assertion] = {
|
||||
for {
|
||||
List(alice, bob, charlie) <- Future.sequence(List.fill(3)(allocateParty))
|
||||
onlySignatories = new OnlySignatories(alice)
|
||||
implicitObservers = new ImplicitObservers(alice, bob)
|
||||
explicitObservers = new ExplicitObservers(alice, bob)
|
||||
mixedObservers = new MixedObservers(alice, bob, charlie)
|
||||
result <- withClient(
|
||||
testCode(alice, onlySignatories, implicitObservers, explicitObservers, mixedObservers, _)
|
||||
testCode(alice, onlySignatories, explicitObservers, _)
|
||||
)
|
||||
} yield result
|
||||
}
|
||||
@ -47,7 +43,7 @@ trait StakeholdersTest
|
||||
behavior of "Stakeholders"
|
||||
|
||||
they should "be exposed correctly for contracts without observers" in withUniqueParties {
|
||||
(alice, onlySignatories, _, _, _, client) =>
|
||||
(alice, onlySignatories, _, client) =>
|
||||
sendCmd(client, alice, onlySignatories.create())
|
||||
|
||||
val contract :: _ =
|
||||
@ -57,19 +53,8 @@ trait StakeholdersTest
|
||||
contract.observers shouldBe empty
|
||||
}
|
||||
|
||||
they should "be exposed correctly for contracts with only implicit observers" in withUniqueParties {
|
||||
(alice, _, implicitObservers, _, _, client) =>
|
||||
sendCmd(client, alice, implicitObservers.create())
|
||||
|
||||
val contract :: _ =
|
||||
readActiveContracts(ImplicitObservers.Contract.fromCreatedEvent)(client, alice)
|
||||
|
||||
contract.signatories should contain only implicitObservers.owner
|
||||
contract.observers should contain only implicitObservers.thirdParty
|
||||
}
|
||||
|
||||
they should "be exposed correctly for contracts with only explicit observers" in withUniqueParties {
|
||||
(alice, _, _, explicitObservers, _, client) =>
|
||||
(alice, _, explicitObservers, client) =>
|
||||
sendCmd(client, alice, explicitObservers.create())
|
||||
|
||||
val contract :: _ =
|
||||
@ -78,16 +63,4 @@ trait StakeholdersTest
|
||||
contract.signatories should contain only explicitObservers.owner
|
||||
contract.observers should contain only explicitObservers.thirdParty
|
||||
}
|
||||
|
||||
they should "be exposed correctly for contracts with both implicit and explicit observers" in withUniqueParties {
|
||||
(alice, _, _, _, mixedObservers, client) =>
|
||||
sendCmd(client, alice, mixedObservers.create())
|
||||
|
||||
val contract :: _ =
|
||||
readActiveContracts(MixedObservers.Contract.fromCreatedEvent)(client, alice)
|
||||
|
||||
contract.signatories should contain only mixedObservers.owner
|
||||
contract.observers should contain.only(mixedObservers.thirdParty1, mixedObservers.thirdParty2)
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user