# Mercury 'Do Loop' 'Continue Do' issue

**URL:** https://talk.remobjects.com/t/mercury-do-loop-continue-do-issue/33083
**Category:** Mercury
**Tags:** mercury
**Created:** [March 16, 2026, 2:00pm UTC](https://talk.remobjects.com/t/mercury-do-loop-continue-do-issue/33083 "2026-03-16T14:00:17Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![chikega](https://talk.remobjects.com/user_avatar/talk.remobjects.com/chikega/32/15211_2.png) [@chikega](https://talk.remobjects.com/u/chikega)
#### Post date: [March 16, 2026, 2:00pm UTC](https://talk.remobjects.com/t/mercury-do-loop-continue-do-issue/33083/1 "2026-03-16T14:00:17Z")

</div>

Hi Marc,

I think I may have found an issue, or at least an ambiguity, with `Continue` inside `Do … Loop` in Mercury.

I tested this minimal example:

```vb
Module Program

  Sub Main(args As String())
    Do
      writeLn("test")
      Continue Do
    Loop
  End Sub

End Module

```

This produces errors like:

- Wrong `Continue` modifier: can not find `Do` in the current context

- One of `do`, `For`, `While` expected, got `End`

If I change `Continue Do` to just `Continue`, it compiles, but of course that creates an infinite loop in this minimal example, which is expected.

What seems more interesting is that in a larger simple example, `Continue Do` does not seem to bind correctly to the enclosing `Do ... Loop`. It appears the compiler/parser is not recognizing the immediate surrounding `Do`, even though the statement is clearly inside that loop and only nested within `If ... End If` blocks.

```vb

Module Program

  Sub Main(args As String())
    Write("What is your name? ")
    Dim name As String = readLn()

    If String.IsNullOrWhiteSpace(name) Then
      writeLn("Name cannot be empty.")
      Return
    End If

    writeLn($"It is nice to meet you, {name}!")

    Dim age As Integer
    Do
      Write("How old are you? ")
      Dim ageInput As String = readLn()

      If Not Integer.TryParse(ageInput, age) Then
        writeLn("Please enter a valid whole number for age.")
        ' Continue Do
        Continue do
      End If

      If age < 0 Then
        writeLn("Age cannot be negative.")
        ' Continue Do
        Continue
      End If

      Exit Do
    Loop

    Dim gpa As Double
    Do
      Write("What is your GPA? ")
      Dim gpaInput As String = readLn()

      If Not Double.TryParse(gpaInput, gpa) Then
        writeLn("Please enter a valid numeric value for GPA.")
        ' Continue Do
        Continue
      End If

      If gpa < 0.0 OrElse gpa > 4.0 Then
        writeLn("GPA must be between 0.0 and 4.0.")
        ' Continue Do
        Continue
      End If

      Exit Do
    Loop

    writeLn($"So, {name}, you are {age} years old and your GPA is {gpa:F2} ... stellar!")
  End Sub

End Module

```

 ![Screenshot 2026-03-16 at 9.54.26 AM](https://talk.remobjects.com/uploads/default/original/3X/5/f/5fcdec0aba9dac722303036d949300f57b24addc.jpeg)  
So my question is:

- Is `Continue Do` unsupported in Mercury?

- Or is this a parser/compiler issue with loop association and/or error reporting?

Thanks,  
Gary

---

<div class="post-metadata">

### Author: ![mh](https://talk.remobjects.com/user_avatar/talk.remobjects.com/mh/32/18050_2.png) [@mh](https://talk.remobjects.com/u/mh)
#### Post date: [March 20, 2026, 11:51pm UTC](https://talk.remobjects.com/t/mercury-do-loop-continue-do-issue/33083/2 "2026-03-20T23:51:37Z")

</div>

> [@chikega](#):
>
> - Wrong `Continue` modifier: can not find `Do` in the current context
> 
> - One of `do`, `For`, `While` expected, got `End`

Curious, it says Do lowercase?

In any case, sounds like a bug; will log.

---

<div class="post-metadata">

### Author: ![RemObjectsSoftware](https://talk.remobjects.com/user_avatar/talk.remobjects.com/remobjectssoftware/32/15947_2.png) [@RemObjectsSoftware](https://talk.remobjects.com/u/RemObjectsSoftware)
#### Post date: [March 20, 2026, 11:52pm UTC](https://talk.remobjects.com/t/mercury-do-loop-continue-do-issue/33083/3 "2026-03-20T23:52:07Z")

</div>

Logged as [bugs://E27590](https://www.remobjects.com/portal/bugs/?id=E27590).

---

<div class="post-metadata">

### Author: ![chikega](https://talk.remobjects.com/user_avatar/talk.remobjects.com/chikega/32/15211_2.png) [@chikega](https://talk.remobjects.com/u/chikega)
#### Post date: [March 22, 2026, 5:40pm UTC](https://talk.remobjects.com/t/mercury-do-loop-continue-do-issue/33083/4 "2026-03-22T17:40:42Z")

</div>

Thanks for taking a look, Marc! 🤓👍

---

<div class="post-metadata">

### Author: ![RemObjectsSoftware](https://talk.remobjects.com/user_avatar/talk.remobjects.com/remobjectssoftware/32/15947_2.png) [@RemObjectsSoftware](https://talk.remobjects.com/u/RemObjectsSoftware)
#### Post date: [April 10, 2026, 7:53am UTC](https://talk.remobjects.com/t/mercury-do-loop-continue-do-issue/33083/5 "2026-04-10T07:53:48Z")

</div>

[bugs://E27590](https://www.remobjects.com/portal/bugs/?id=E27590) was closed as fixed.

---

<div class="post-metadata">

### Author: ![chikega](https://talk.remobjects.com/user_avatar/talk.remobjects.com/chikega/32/15211_2.png) [@chikega](https://talk.remobjects.com/u/chikega)
#### Post date: [April 11, 2026, 4:50pm UTC](https://talk.remobjects.com/t/mercury-do-loop-continue-do-issue/33083/6 "2026-04-11T16:50:17Z")

</div>

I can confirm that the issue has been rectified with the latest build .3073  
Thank you @mh ! 🚀🚀🚀

```vb
Module Program

  Sub Main(args As String())
    Dim i As Integer = 0

    Do
      If i = 10 Then
        Exit Do
      Else
        Console.WriteLine($"{i}) test")
        i += 1
        Continue Do
      End If
    Loop

  End Sub

End Module

```

Output:

```bash
0) test
1) test
2) test
3) test
4) test
5) test
6) test
7) test
8) test
9) test

```

---

<div class="post-metadata">

### Author: ![mh](https://talk.remobjects.com/user_avatar/talk.remobjects.com/mh/32/18050_2.png) [@mh](https://talk.remobjects.com/u/mh)
#### Post date: [April 11, 2026, 7:35pm UTC](https://talk.remobjects.com/t/mercury-do-loop-continue-do-issue/33083/7 "2026-04-11T19:35:40Z")

</div>

> [@chikega](#):
>
> I can confirm that the issue has been rectified with the latest build .3073  
> Thank you @mh ! 🚀🚀🚀

Happy to hear! Thanx for confirming.
