Couldn't match type 'Scenario' with 'Script'
- nemanjaOP
Hi Damlers

I have a very simple Daml script that used to work:
test = script do alice <- allocateParty "Alice" p <- submit alice $ createCmd $ PersonContract {name = alice, address = Address {street = "RabbitStreet", city = "QueenOfHearts", country = "Wonderland"}, age = 7} submit alice $ do c <- fetch p assert $ c.name == aliceTrying to run it now i get the following error:
/root/organizer/daml/AddressBook.daml:32:3: error: • Couldn't match type 'Scenario' with 'Script' arising from a functional dependency between: constraint 'HasSubmit Script Update' arising from a use of 'submit' instance 'HasSubmit Scenario Update' at <no location info> • In the expression: submit alice In a stmt of a 'do' block: submit alice $ do c <- fetch p assert $ (getField @"name" c) == alice In the first argument of 'script', namely 'do alice <- allocateParty "Alice"What’s the reason for it?
- cocreature 2
Hi @nemanja,
First, just to avoid confusion: This was never a valid Daml Script. However, if you replace
allocatePartybygetPartyandcreateCmdbycreateandscriptbyscenarioit is a valid scenario. So it broke by migrating it to a Script.The reason for that is documented in the migration guide in point 5.2. Applying that switch from
fetchtoqueryContractId, you end up withtest = script do alice <- allocateParty "Alice" p <- submit alice $ createCmd $ PersonContract {name = alice, address = Address {street = "RabbitStreet", city = "QueenOfHearts", country = "Wonderland"}, age = 7} Some c <- queryContractId alice p assert $ c.name == aliceYou might also want to switch the last line to
c.name === alicewhich provides you with a better error message on failure. Note that you need to add an extra import toDA.Assertfor that to compile.