# Quicktest Error: "It is illegal to fall out of a \*choice statement"

**URL:** <https://forum.choiceofgames.com/t/quicktest-error-it-is-illegal-to-fall-out-of-a-choice-statement/14139>\
**Category:** ChoiceScript Help\
**Created:** [January 5, 2016, 8:12am UTC](https://forum.choiceofgames.com/t/quicktest-error-it-is-illegal-to-fall-out-of-a-choice-statement/14139 "2016-01-05T08:12:54Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![555sarin](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/555sarin/32/8825_2.png) [@555sarin](https://forum.choiceofgames.com/u/555sarin)\
**Post date:** [January 5, 2016, 8:12am UTC](https://forum.choiceofgames.com/t/quicktest-error-it-is-illegal-to-fall-out-of-a-choice-statement/14139/1 "2016-01-05T08:12:54Z")

</div>

Can anyone tell what I did wrong here?

When I use quicktest and randomtest it said ‘It is illegal to fall out of a \*choice statement; you must \*goto or \*finish before the end of the indented block.’ But when I manually test it myself it got no error on the same part. Can anyone figure what is wrong with my code below?

It always got error at the #Brown hair and other, but not #Black hair.

```
*choice
  #Skull structure that is a standard of healthy human. 
    As you look at your face, you reminded yourself that you are a human. The most...

    You look at your human face and its...
    *set race1 true
    *set stren + 2
    *set agil +2
    *set intel + 2
    *set char + 2
    *choice
      #Black hair
        which goes along nicely with your...
        *if (male = true)
          *set haircs "short black"
          *goto eyec
        *elseif (female = true)
          *set haircs "ponytail black"
          *goto eyec
      #Brown hair
        which goes along nicely with your...
        *if (male = true)
          *set haircs "short brown"
          *goto eyec
        *elseif (female = true)
          *set haircs "ponytail brown"
          *goto eyec
      #Blonde hair
        which goes along nicely with your...
        *if (male = true)
          *set haircs "short blonde"
          *goto eyec
        *elseif (female = true)
          *set haircs "ponytail blonde"
          *goto eyec
      #Red hair
        which goes along nicely with your...
        *if (male = true)
          *set haircs "short red"
          *goto eyec
        *elseif (female = true)
          *set haircs "ponytail red"
          *goto eyec
```

---

<div class="post-metadata">

**Author:** ![Havenstone](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/havenstone/32/198451_2.png) [@Havenstone](https://forum.choiceofgames.com/u/Havenstone)\
**Post date:** [January 5, 2016, 8:48am UTC](https://forum.choiceofgames.com/t/quicktest-error-it-is-illegal-to-fall-out-of-a-choice-statement/14139/2 "2016-01-05T08:48:55Z")

</div>

There was just a thread about this. 🙂[[RESOLVED] Problem with \*if and \*elseif - #11 by Havenstone](https://forum.choiceofgames.com/t/resolved-problem-with-if-and-elseif/14035/11)

The problem is that if both male and female were false, the game would crash. QT will pick that up as a bug.

Use else instead of elseif and it’ll work.

---

<div class="post-metadata">

**Author:** ![RETowers](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/retowers/32/21477_2.png) [@RETowers](https://forum.choiceofgames.com/u/RETowers)\
**Post date:** [January 5, 2016, 8:49am UTC](https://forum.choiceofgames.com/t/quicktest-error-it-is-illegal-to-fall-out-of-a-choice-statement/14139/3 "2016-01-05T08:49:42Z")

</div>

Quick test ‘cheats’ when it tests. It doesn’t track what it’s doing, it just checks for typos (mostly). When it gets to an \*if, it doesn’t remember what it’s done, it just tests both sides.

\*In this case, you shouldn’t be use \*elseif you should just use _else_. Otherwise, when quicktest gets to the male if, it tests both sides (male = true and male != true). Then when it gets to the next part, it does the same thing again. (Female = true Female != true).

---

<div class="post-metadata">

**Author:** ![555sarin](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/555sarin/32/8825_2.png) [@555sarin](https://forum.choiceofgames.com/u/555sarin)\
**Post date:** [January 5, 2016, 9:26am UTC](https://forum.choiceofgames.com/t/quicktest-error-it-is-illegal-to-fall-out-of-a-choice-statement/14139/4 "2016-01-05T09:26:29Z")

</div>

ty all, for answering me, I am looking forward to share this game with you guys.

---

<div class="post-metadata">

**Author:** ![555sarin](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/555sarin/32/8825_2.png) [@555sarin](https://forum.choiceofgames.com/u/555sarin)\
**Post date:** [January 5, 2016, 4:59pm UTC](https://forum.choiceofgames.com/t/quicktest-error-it-is-illegal-to-fall-out-of-a-choice-statement/14139/5 "2016-01-05T16:59:44Z")

</div>

I got another error, same kind of error. But there are no \*if or \*elseif in this one.

```
  #Act
    *choice
      #Talk to it
        You have a pleasant conversation
        *set like + 10
        *goto good
      #Wait...
        Okay, why?
        *goto stun_check
      #Nevermind
        *goto fight
```

---

<div class="post-metadata">

**Author:** ![Dark\_Jester](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/dark_jester/32/7852_2.png) [@Dark\_Jester](https://forum.choiceofgames.com/u/Dark_Jester)\
**Post date:** [January 5, 2016, 6:02pm UTC](https://forum.choiceofgames.com/t/quicktest-error-it-is-illegal-to-fall-out-of-a-choice-statement/14139/6 "2016-01-05T18:02:50Z")

</div>

I’m having the same problem. An error shows up when there’s nothing wrong. It’s annoying as hell. 😡 Hope you get an answer.

---

<div class="post-metadata">

**Author:** ![TheBellaNotte](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/thebellanotte/32/7220_2.png) [@TheBellaNotte](https://forum.choiceofgames.com/u/TheBellaNotte)\
**Post date:** [January 5, 2016, 6:14pm UTC](https://forum.choiceofgames.com/t/quicktest-error-it-is-illegal-to-fall-out-of-a-choice-statement/14139/7 "2016-01-05T18:14:25Z")

</div>

I have seen this same error when my \*choice statements lead to \*gosub. I tried adding \*finish after (on the next line) and that seemed to resolve the error. Maybe try that and see if it works for you? 🙂

---

<div class="post-metadata">

**Author:** ![RETowers](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/retowers/32/21477_2.png) [@RETowers](https://forum.choiceofgames.com/u/RETowers)\
**Post date:** [January 5, 2016, 6:15pm UTC](https://forum.choiceofgames.com/t/quicktest-error-it-is-illegal-to-fall-out-of-a-choice-statement/14139/8 "2016-01-05T18:15:44Z")

</div>

Check the line number (main reason to get Notepad++ over Notepad if you’re on windows), because that’s not the entire code, and there’s no way for someone to guess where your errors are.

---

<div class="post-metadata">

**Author:** ![Havenstone](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/havenstone/32/198451_2.png) [@Havenstone](https://forum.choiceofgames.com/u/Havenstone)\
**Post date:** [January 6, 2016, 2:25am UTC](https://forum.choiceofgames.com/t/quicktest-error-it-is-illegal-to-fall-out-of-a-choice-statement/14139/9 "2016-01-06T02:25:55Z")

</div>

I know even with a line # it’s sometimes been non-obvious to me where the error was – IIRC, quicktest would list a line just above or below the offending block of code. But I was ultimately always able to figure out something that would make it go away.

---

<div class="post-metadata">

**Author:** ![Dark\_Jester](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/dark_jester/32/7852_2.png) [@Dark\_Jester](https://forum.choiceofgames.com/u/Dark_Jester)\
**Post date:** [January 6, 2016, 3:14am UTC](https://forum.choiceofgames.com/t/quicktest-error-it-is-illegal-to-fall-out-of-a-choice-statement/14139/10 "2016-01-06T03:14:35Z")

</div>

This is what the one choice that is apparently being illegal looks like.

```
#"This is a choice that works fine when I play it, just not in quicktest."
     Blah blah blag bibbidy bloobidy blah. 
     Blah blah blah balahhhhhhh.

     Baggidy biggidy blah blah boo balah.
     *set something_something_something true
     *goto this_is_the_goto
     *finish

```

I changed the words but everything else is the same, including the use of underscores.  
Also that goto does lead to a label. I’ve made sure multiple times. The spelling and all that is correct. I tried putting finish after the goto like TheBellaNotte suggested. I’m also using notepad ++ so I know exactly which choice has the problem. It still tells me I’m illegal. But I really think I’ve been a good citizen and followed all the laws. This is police brutality in my opinion. 😭

---

<div class="post-metadata">

**Author:** ![555sarin](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/555sarin/32/8825_2.png) [@555sarin](https://forum.choiceofgames.com/u/555sarin)\
**Post date:** [January 6, 2016, 5:41am UTC](https://forum.choiceofgames.com/t/quicktest-error-it-is-illegal-to-fall-out-of-a-choice-statement/14139/11 "2016-01-06T05:41:56Z")

</div>

I found the way to fix it. Apparently the choices before this one that have \*if (var = true) have to always end with \*else or it will not pass. The number \*if (var = 1) can end with \*elseif though.

Also do anyone ever fix this bug?

---

<div class="post-metadata">

**Author:** ![Havenstone](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/havenstone/32/198451_2.png) [@Havenstone](https://forum.choiceofgames.com/u/Havenstone)\
**Post date:** [January 6, 2016, 6:35am UTC](https://forum.choiceofgames.com/t/quicktest-error-it-is-illegal-to-fall-out-of-a-choice-statement/14139/12 "2016-01-06T06:35:58Z")

</div>

@Dark_Jester: Ah, but that’s not the whole choice. What’s going on with the other #options? In my experience, the specific line QT highlights isn’t always the one that needs changing to fix the error.

Also, it wouldn’t cause this error, but you’d not reach the \*finish after the \*goto.

@555sarin, it’s not a bug. Read [https://www.choiceofgames.com/make-your-own-games/testing-choicescript-games-automatically/#fakes](https://www.choiceofgames.com/make-your-own-games/testing-choicescript-games-automatically/#fakes) to see why.

---

<div class="post-metadata">

**Author:** ![Dark\_Jester](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/dark_jester/32/7852_2.png) [@Dark\_Jester](https://forum.choiceofgames.com/u/Dark_Jester)\
**Post date:** [January 8, 2016, 1:52am UTC](https://forum.choiceofgames.com/t/quicktest-error-it-is-illegal-to-fall-out-of-a-choice-statement/14139/13 "2016-01-08T01:52:48Z")

</div>

I’ve checked all the other #options as well. They all end with goto or goto\_scene. The scene exists, the labels that the choices goto exist. Everything is spelt correctly. It works when I play it. Nothing is wrong.

Also I put \*finish after that goto because it fixed the problem for TheBellaNotte so I was seeing if it would work for me, unfortunately it didn’t. I know it would never reach the finish.

---

<div class="post-metadata">

**Author:** ![Havenstone](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/havenstone/32/198451_2.png) [@Havenstone](https://forum.choiceofgames.com/u/Havenstone)\
**Post date:** [January 8, 2016, 10:05am UTC](https://forum.choiceofgames.com/t/quicktest-error-it-is-illegal-to-fall-out-of-a-choice-statement/14139/14 "2016-01-08T10:05:55Z")

</div>

Ah, got it. Are any of the choices conditional?

If you PM me the actual undisguised code, I promise not to steal any of your story or code – pinky swear. It’ll be [available to the world](https://forum.choiceofgames.com/t/how-to-see-other-games-code/1328/9) once your game is tested and published, in any case… and it’s hard to diagnose where QT is getting flustered without seeing the actual code.

---

<div class="post-metadata">

**Author:** ![Dark\_Jester](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/dark_jester/32/7852_2.png) [@Dark\_Jester](https://forum.choiceofgames.com/u/Dark_Jester)\
**Post date:** [January 8, 2016, 12:24pm UTC](https://forum.choiceofgames.com/t/quicktest-error-it-is-illegal-to-fall-out-of-a-choice-statement/14139/15 "2016-01-08T12:24:31Z")

</div>

Oh yeah, I’ll send it to you if you want.

---

<div class="post-metadata">

**Author:** ![Havenstone](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/havenstone/32/198451_2.png) [@Havenstone](https://forum.choiceofgames.com/u/Havenstone)\
**Post date:** [January 11, 2016, 5:18pm UTC](https://forum.choiceofgames.com/t/quicktest-error-it-is-illegal-to-fall-out-of-a-choice-statement/14139/16 "2016-01-11T17:18:59Z")

</div>

Since others may come to this thread and be interested to know what the solution ended up being, here’s an equivalent example (I don’t want to give away anything about @Dark_Jester’s actual game, so this is totally unrelated).

Imagine a game, _Choice of the US Senator_, where you have to choose between being Republican or Democrat – no third parties. And QT was giving you the error message for a line around this choice:

```
*choice
  #Make your base happy!
    *if republican
      You successfully shrink the government until it can be drowned in a bathtub-- all except the military, of course.
      *goto fallout_4
    *if democrat
      You buy every family in America a new national park (and hold pangender marriage ceremonies in them).
      *goto out_of_cash
  #Stick to the middle of the road.
      You are the image of fiscal responsibility and bipartisan consensus building.
      *goto lose_election
  #Depose the President and establish a parliamentary system.
    On the plus side, you can now pass laws with far less gridlock.
    *goto civil_war

```

The reason QuickTest would choke on this code is that QT doesn’t know the US has a two-party duopoly. So it checks to see what happens if a not-republican not-democrat chooses option 1… and the code crashes, because there’s no option for that. (Basically, the same problem highlighted with male/female in the [CoG example](https://www.choiceofgames.com/make-your-own-games/testing-choicescript-games-automatically/#fakes) – but it gets harder to see when there’s a lot more text involved, as there was in Dark\_Jester’s choice).

A few things could be done to fix this. The one D\_J used was to add

```
*else
  *finish

```

with the `*else` indented to the same depth as `*if republican` and `*if democrat`. That reassures QT that a not-republican not-democrat Senator can still keep playing the game after this choice – even if in the actual game, such a Senator would be impossible.

Alternately, changing `*if democrat` to `*else` or `*if not(republican)` should pass QuickTest too.

So if you’re getting this error, look to see where you’ve got an `*if boolean1`, `*if boolean2` etc. in your choice, and make sure that there’s a way forward for the “not(boolean1) and not(boolean2)” reader.

---

<div class="post-metadata">

**Author:** ![dfabulich](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/dfabulich/32/198373_2.png) [@dfabulich](https://forum.choiceofgames.com/u/dfabulich)\
**Post date:** [January 11, 2016, 5:49pm UTC](https://forum.choiceofgames.com/t/quicktest-error-it-is-illegal-to-fall-out-of-a-choice-statement/14139/17 "2016-01-11T17:49:24Z")

</div>

In a bizarre coincidence, I happen to have updated the documentation yesterday to use “republican” and “democrat” instead of “male” and “female” in the official example.

Great minds think alike, I suppose!

---

<div class="post-metadata">

**Author:** ![Havenstone](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/havenstone/32/198451_2.png) [@Havenstone](https://forum.choiceofgames.com/u/Havenstone)\
**Post date:** [January 11, 2016, 7:04pm UTC](https://forum.choiceofgames.com/t/quicktest-error-it-is-illegal-to-fall-out-of-a-choice-statement/14139/18 "2016-01-11T19:04:44Z")

</div>

Suppose that must be it. 🙂

---

<div class="post-metadata">

**Author:** ![555sarin](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/555sarin/32/8825_2.png) [@555sarin](https://forum.choiceofgames.com/u/555sarin)\
**Post date:** [February 1, 2016, 2:07pm UTC](https://forum.choiceofgames.com/t/quicktest-error-it-is-illegal-to-fall-out-of-a-choice-statement/14139/19 "2016-02-01T14:07:55Z")

</div>

I got another error, plz look.

```
  #Drink Health Potion
    *if (hp_p <= 0)
      You don't have any right now. [You can always check the number of your potions. If you don't have any and still click this choice anyway you will lose a turn.]
      *goto stun_check
    *if (hp_p > 0)
      You drink a health potion.
      *set hp + 15
      *if (hp > max_hp)
        *set hp max_hp
        *goto stun_check
      *else
        *goto stun_check
  #Drink Energy Potion
    *if (energy_p <= 0)
      You don't have any right now.[You can always check the number of your potions. If you don't have any and still click this choice anyway you will lose a turn.]
      *goto stun_check
    *if (energy_p > 0)
      You drink an energy potion.
      *set energy + 10
      *if (energy > max_energy)
        *set energy max_energy
        *goto stun_check
      *else
        *goto stun_check
  #Nevermind
    *goto fight

```

It said only the ‘Drink Energy Potion’ is the one falling out. So why is the health potion isn’t falling out? And what did I do wrong here?

---

<div class="post-metadata">

**Author:** ![Havenstone](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/havenstone/32/198451_2.png) [@Havenstone](https://forum.choiceofgames.com/u/Havenstone)\
**Post date:** [February 1, 2016, 2:33pm UTC](https://forum.choiceofgames.com/t/quicktest-error-it-is-illegal-to-fall-out-of-a-choice-statement/14139/20 "2016-02-01T14:33:08Z")

</div>

If you swap your `*if [stat] > 0` lines for `*else`s does that fix it?

[Next page](https://forum.choiceofgames.com/t/quicktest-error-it-is-illegal-to-fall-out-of-a-choice-statement/14139.md?page=2)
