# Last statement in a do block must be an expression?

**URL:** <https://forum.canton.network/t/last-statement-in-a-do-block-must-be-an-expression/638>\
**Category:** App Development\
**Tags:** daml\
**Created:** [June 9, 2020, 9:00pm UTC](https://forum.canton.network/t/last-statement-in-a-do-block-must-be-an-expression/638 "2020-06-09T21:00:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![bartcant](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/bartcant/32/823_2.png) [@bartcant](https://forum.canton.network/u/bartcant)\
**Post date:** [June 9, 2020, 9:00pm UTC](https://forum.canton.network/t/last-statement-in-a-do-block-must-be-an-expression/638/1 "2020-06-09T21:00:36Z")

</div>

**Mod note: As of SDK 1.5.0 Scenarios have been superseded by the more powerful [Daml Script](https://docs.daml.com/daml-script/index.html). 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](https://daml.com/blog/engineering/daml-script-scenarios-2-0/).**

I am hitting a snag in the scenario. I hope you can help pinpoint the problem

> ```
> example = scenario do
> 
> alice <- getParty "Alice"
> bob <- getParty "Bob"
> let citizenkey = CitizenKey with citizen = alice ; id = "1"
> let citizeninfo = CitizenInfo with citizendetail1 = "Text1" ; citizendetail2 ="Text2" ; citizendetail3 = "Text3" 
> 
> submit alice do 
> create CitizenRegistration with registrationCid = citizenkey; registrationData = citizeninfo
> 
>  
> let citizenkey = CitizenKey with citizen = bob ; id = "2" 
> let citizeninfo = CitizenInfo with citizendetail1 = "Text1" ; citizendetail2 ="Text2" ; citizendetail3 = "Text3" 
> 
> bobregistration <- submit bob do 
> create CitizenRegistration with 
> registrationCid = citizenkey; registrationData = citizeninfo
> 
> ```

I trying to understand the correct format for

> ```
> bobregistration <- submit bob do 
> create CitizenRegistration with 
> registrationCid = citizenkey; registrationData = citizeninfo
> 
> ```

It gives me the following error

> ```
> error:
> The last statement in a 'do' block must be an expression
> bobregistration <- submit
> bob
> do create
> CitizenRegistration
> {registrationCid = citizenkey, registrationData = citizeninfo}typecheck
> 
> ```

---

<div class="post-metadata">

**Author:** ![jamesljaworski85](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/jamesljaworski85/32/385_2.png) [@jamesljaworski85](https://forum.canton.network/u/jamesljaworski85)\
**Post date:** [June 9, 2020, 9:10pm UTC](https://forum.canton.network/t/last-statement-in-a-do-block-must-be-an-expression/638/2 "2020-06-09T21:10:54Z")

</div>

Hey @bartcant. It looks to me like you need a return statement at the end of your scenario. Without a return statement, you won’t be able to return the result for both Alice and Bob’s registration.

```
example = scenario do

  alice <- getParty "Alice"
  bob <- getParty "Bob"
  let citizenkey = CitizenKey with citizen = alice ; id = "1"
  let citizeninfo = CitizenInfo with citizendetail1 = "Text1" ; citizendetail2 ="Text2" ; citizendetail3 = "Text3" 

  aliceRegistration <- submit alice do create CitizenRegistration with registrationCid = citizenkey; registrationData = citizeninfo

  let citizenkey = CitizenKey with citizen = bob ; id = "2" 
  let citizeninfo = CitizenInfo with citizendetail1 = "Text1" ; citizendetail2 ="Text2" ; citizendetail3 = "Text3" 

  bobRegistration <- submit bob do create CitizenRegistration with registrationCid = citizenkey; registrationData = citizeninfo
  return(aliceRegistration, bobRegistration)
```

---

<div class="post-metadata">

**Author:** ![rohanjr](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/rohanjr/32/259_2.png) [@rohanjr](https://forum.canton.network/u/rohanjr)\
**Post date:** [June 9, 2020, 9:54pm UTC](https://forum.canton.network/t/last-statement-in-a-do-block-must-be-an-expression/638/3 "2020-06-09T21:54:59Z")

</div>

That’s right. It looks like formatting of the `do` in

> [@bartcant](#):
>
> `bobregistration <- submit bob do `

is fine but the compiler is complaining about the top level scenario:

> [@bartcant](#):
>
> `example = scenario do`

As @jamesljaworski85 pointed out, the last statement of a `do` can’t be a `<-` (or `let`) binding. However it could be something other than `return` if it has the right type, e.g. a `create`.
