# \`if \<conditional\> true else \<falsy\> end\` throwing error

**URL:** <https://forum.crystal-lang.org/t/if-conditional-true-else-falsy-end-throwing-error/3291>\
**Category:** Help & Support\
**Created:** [May 12, 2021, 4:06am UTC](https://forum.crystal-lang.org/t/if-conditional-true-else-falsy-end-throwing-error/3291 "2021-05-12T04:06:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![code-shoily](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/code-shoily/32/1251_2.png) [@code-shoily](https://forum.crystal-lang.org/u/code-shoily)\
**Post date:** [May 12, 2021, 4:06am UTC](https://forum.crystal-lang.org/t/if-conditional-true-else-falsy-end-throwing-error/3291/1 "2021-05-12T04:06:37Z")

</div>

Hello, I am learning Crystal and am exploring the syntax. Few days ago I wanted to try the expression: `if x == 10 true else false end`, that seemed to throw an error: `Error: unexpected token: true`. However, the multiline version of this works, and in single line version, any other value than a `Bool` works (i.e. `if x == 10 :true else false end` works). Is there any particular reason why a `Bool` wouldn’t work in a one liner conditional?

Thank you.

---

<div class="post-metadata">

**Author:** ![asterite](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/asterite/32/60_2.png) [@asterite](https://forum.crystal-lang.org/u/asterite)\
**Post date:** [May 12, 2021, 9:40am UTC](https://forum.crystal-lang.org/t/if-conditional-true-else-falsy-end-throwing-error/3291/2 "2021-05-12T09:40:56Z")

</div>

It’s a bug. I think none should compile, you need a semicolon in every case.

---

<div class="post-metadata">

**Author:** ![straight-shoota](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/straight-shoota/32/36_2.png) [@straight-shoota](https://forum.crystal-lang.org/u/straight-shoota)\
**Post date:** [May 19, 2021, 4:41pm UTC](https://forum.crystal-lang.org/t/if-conditional-true-else-falsy-end-throwing-error/3291/3 "2021-05-19T16:41:05Z")

</div>

Currently, after a condition is parsed, the parser basically just continues parsing the next expression (which is then part of the condition’s branch). There is no explicit requirement for an expression separator (newline or semi-colon). The only restriction (by `parse_op_assign(allow_suffix: false)`) is that the first token after the expression cannot be an identifier. Hence `true` does not work, but `:true` does (`true` is lexed as an identifier).

This applies to all conditional clauses, not just `if`.

I think it would be reasonable to require an expression separator after the condition. This is mandatory in `Ruby`, too.
