Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix invalid/misleading syntax in example docs #11459

Closed
wants to merge 1 commit into from

Conversation

ghost
Copy link

@ghost ghost commented Oct 29, 2021

The docs make it look like it's valid daml to write

  Complete : ()

        do
          -- bind the ledger effective time to the tchoose variable using getTime
          tchoose <- getTime

implying that binding a variable at the end of a do block is ok. This broadens the example to show the variable being used (it's possible that this was broken by a change to the snippets file)

This change now includes more context:

    controller party can
      -- A choice using a check on the current time
      Complete : ()

        do
          -- bind the ledger effective time to the tchoose variable using getTime
          tchoose <- getTime
          -- assert that tchoose is no earlier than the begin time
          assert (begin <= tchoose && tchoose < addRelTime begin period)

Pull Request Checklist

  • Read and understand the contribution guidelines
  • Include appropriate tests
  • Set a descriptive title and thorough description
  • Add a reference to the issue this PR will solve, if appropriate
  • Include changelog additions in one or more commit message bodies between the CHANGELOG_BEGIN and CHANGELOG_END tags
  • Normal production system change, include purpose of change in description
  • If you mean to change the status of a component, please make sure you keep the Component Status page up to date.

NOTE: CI is not automatically run on non-members pull-requests for security
reasons. The reviewer will have to comment with /AzurePipelines run to
trigger the build.

The docs make it look like it's valid daml to write 

```haskell
  Complete : ()

        do
          -- bind the ledger effective time to the tchoose variable using getTime
          tchoose <- getTime
```
implying that binding a variable at the end of a do block is ok. This broadens the example to show the variable being used (it's possible that this was broken by a change to the snippets file)

This change now includes more context:

```Haskell
    controller party can
      -- A choice using a check on the current time
      Complete : ()

        do
          -- bind the ledger effective time to the tchoose variable using getTime
          tchoose <- getTime
          -- assert that tchoose is no earlier than the begin time
          assert (begin <= tchoose && tchoose < addRelTime begin period)
```
@ghost ghost requested review from bame-da and nemanja-da as code owners October 29, 2021 04:45
@@ -181,7 +181,7 @@ Here's an example of a choice that uses a check on the current time:

.. literalinclude:: ../code-snippets/Snippets.daml
:language: daml
:lines: 42-46
:lines: 40-48
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rather than switching around the line numbers which might get broken again by #11363 I’d recommend fixing this by switching over to :start-after: and :end-before and putting a marker in the snippet. That is much more robust against changes.

@digitalasset-cla
Copy link
Member

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@garyverhaegen-da
Copy link
Contributor

This has been resolved in the meantime, using @cocreature's suggestion of using references instead of line numbers. Current version can be seen here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants