-
Notifications
You must be signed in to change notification settings - Fork 205
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
interfaces: Add fixed choice collision check in typechecker (Haskell) (…
…#11337) * interfaces: Add fixed choice name collision check Add a check that a template cannot have two choices with the same name, even taking into account all of its "inherited" interface fixed choices. Part of #11137 changelog_begin changelog_end * "Me want" -> "We want"
- Loading branch information
1 parent
c37ecd1
commit ed9dbed
Showing
3 changed files
with
62 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
compiler/damlc/tests/daml-test-files/InterfaceChoiceCollision.daml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
-- Copyright (c) 2021 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. | ||
-- SPDX-License-Identifier: Apache-2.0 | ||
|
||
-- @SINCE-LF-FEATURE DAML_INTERFACE | ||
-- @ERROR Duplicate choice name 'MyArchive' in template T via interfaces. | ||
module InterfaceChoiceCollision where | ||
|
||
interface InterfaceA where | ||
getOwnerA : Party | ||
|
||
choice MyArchive : () | ||
controller getOwnerA this | ||
do pure () | ||
|
||
interface InterfaceB where | ||
getOwnerB : Party | ||
|
||
-- We want InterfaceB to have a fixed choice with the same name as InterfaceA, | ||
-- but we can't add it via the fixed choice syntax in the same file because that | ||
-- would result in a duplicate `data` declaration for MyArchive. So instead we | ||
-- add the fixed choice manually (see InterfaceDesugared for comparison). | ||
_choice_InterfaceBMyArchive : | ||
( InterfaceB -> MyArchive -> [DA.Internal.Desugar.Party] | ||
, DA.Internal.Desugar.ContractId InterfaceB -> InterfaceB -> MyArchive -> DA.Internal.Desugar.Update () | ||
, DA.Internal.Desugar.Consuming InterfaceB | ||
, DA.Internal.Desugar.Optional (InterfaceB -> MyArchive -> [DA.Internal.Desugar.Party]) | ||
) | ||
_choice_InterfaceBMyArchive = | ||
( \this _ -> [getOwnerB this] | ||
, \_ _ _ -> pure () | ||
, DA.Internal.Desugar.Consuming | ||
, DA.Internal.Desugar.None | ||
) | ||
|
||
template T with | ||
owner : Party | ||
where | ||
signatory owner | ||
implements InterfaceA where | ||
let getOwnerA = owner | ||
implements InterfaceB where | ||
let getOwnerB = owner |