# Painless empty block?

**URL:** <https://discuss.elastic.co/t/painless-empty-block/155213>\
**Category:** Elasticsearch\
**Created:** [November 2, 2018, 5:17pm UTC](https://discuss.elastic.co/t/painless-empty-block/155213 "2018-11-02T17:17:31Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![m9aertner](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/m9aertner/32/39588_2.png) [@m9aertner](https://discuss.elastic.co/u/m9aertner)\
**Post date:** [November 6, 2018, 10:29am UTC](https://discuss.elastic.co/t/painless-empty-block/155213/3 "2018-11-06T10:29:19Z")

</div>

We're _generating_ painless scripts from higher-level condition representations. One obvious workaround there is to prevent _the generator_ from outputting the condition in the first place, when the block would be empty. Or, add a no-op like "true", as above. Or, like you say, re-write to remove the whole "if".

Certainly, this is not a bug. I think it's just _odd_. Don't have practically all bracket-style languages a definition for "block-statement" like "block-statement := { statement-list }" with "statement-list := empty, or a statement-list followed by a statement".

Well, Painless apparently does not. Fair enough, NP. Of course, the purpose of this note is to help anyone wondering about the error message "Extraneous if statement" (like [Painless is a pain in my head](https://discuss.elastic.co/t/painless-is-a-pain-in-my-head/85612) and [https://stackoverflow.com/q/50211148](https://stackoverflow.com/q/50211148))

---

_[View the full topic](https://discuss.elastic.co/t/painless-empty-block/155213)._
