harec

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 97e68dda83471aea74f5eea64ff3b865b1fc99de
parent 82ab160673910c73fcbf6a038d200cf2b099fac3
Author: Eyal Sawady <ecs@d2evs.net>
Date:   Sat, 27 Feb 2021 16:08:40 -0500

Fix labelled break/continue in unlabelled loops

Diffstat:
Msrc/gen.c | 2+-
Mtests/12-loops.ha | 7++++++-
2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/gen.c b/src/gen.c @@ -1593,7 +1593,7 @@ gen_expr_control(struct gen_context *ctx, if (strcmp(expr->control.label, scope->label) == 0) { break; } - } else if (scope->class == SCOPE_LOOP) { + } else if (!expr->control.label && scope->class == SCOPE_LOOP) { break; } scope = scope->parent; diff --git a/tests/12-loops.ha b/tests/12-loops.ha @@ -77,7 +77,12 @@ fn label() void = { :inner for (let j = 0; j < 7; j += 1) { i += 1; if (j == 6) { - continue :inner; + for (let k = 0; k < 5; k += 1) { + if (k == 2) { + continue :inner; + }; + assert(k < 2); + }; }; assert(j != 6); if (i > 7) {