Why do I need to indent so much when constructing (not creating) a contract?
- SamirTalwarOP 4
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
withblock 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
withblock, so it looks like this:let person = Person with owner = alice name = "Alice" dateOfBirth = date 2020 Jan 1Then 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
withblock.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?
- cocreature 3
You need to indent further than the name of the variable you are defining in your
let. Inlet person = Person with owner = aliceyou are defining 2 let-bindings,
personis bound toPerson with(so no fields which is why you are getting the error) andowneris bound toalice. - SamirTalwar 1
Thanks @cocreature! I didn’t realize I could define multiple values in a single
let.