We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Is it Volt's bug?

I wrote my code in template like below

{% for stage in 1..1 %}
    {% if true  %}
        1
            {% for a in [] %}
                {% for b in [] %}
                {% endfor %}
            {% endfor %}
    {% else %}
        2
    {% endif %}
{% endfor %}

The condition should always be true, but the code output both '1' and '2'.

1 2

Is it a bug?

This is really strange.. This is the generated PHP file from your code:

<?php foreach (range(1, 1) as $stage) { ?>
    <?php if (true) { ?>
        1
            <?php foreach (array() as $a) { ?>
                <?php foreach (array() as $b) { ?>
                <?php } ?>
            <?php } ?>

        2
    <?php } ?>
<?php } ?>

Removing the inner loops fixes the problem, but thats strange.