Mod note: As of SDK 1.5.0 Scenarios have been superseded by the more powerful Daml Script. We now recommend using that for all purposes. For more information, and to learn how to use Script please check out @Andreas’ post on our blog.
I seem to need at least 5 spaces when indenting a with
block in constructing a contract.
For example:
template Person
with
owner : Party
name : Text
dateOfBirth : Date
where
signatory owner
test = scenario do
alice <- getParty "Alice"
let person = Person with
owner = alice
name = "Alice"
dateOfBirth = date 2020 Jan 1
person.name === "Alice"
If I dedent the with
block, so it looks like this:
let person = Person with
owner = alice
name = "Alice"
dateOfBirth = date 2020 Jan 1
Then I get the following error:
• Constructor ‘Person’ does not have the required strict field(s): owner,
name, dateOfBirth
• In the expression: Person {}
In an equation for ‘person’: person = Person {}
It appears as if the parser is recognizing nothing inside the with
block.
If I go down to 2 spaces, I get an error on the first =
:
parse error on input ‘=’
Why do I need so much whitespace?