From 9edace28e2e43fb8cb8dc64191b3ed3f5a185f99 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Tue, 13 Aug 2024 03:20:01 -0400 Subject: Fix ranges --- compile.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'compile.c') diff --git a/compile.c b/compile.c index 4be2abb5..c8edd5fb 100644 --- a/compile.c +++ b/compile.c @@ -850,8 +850,9 @@ CORD compile_statement(env_t *env, ast_t *ast) return CORD_all( "{\n" "const Range_t range = ", range, ";\n" - "if (range.step == 0) fail(\"This range has a 'step' of zero and will loop infinitely!\");\n" - "for (int64_t ", value, " = range.first; range.step > 0 ? ", value, " <= range.last : ", value, " >= range.last; ", value, " += range.step) {\n" + "if (range.step.small == 0) fail(\"This range has a 'step' of zero and will loop infinitely!\");\n" + "bool negative = (Int$compare_value(range.step, I(0)) < 0);\n" + "for (Int_t ", value, " = range.first; negative ? Int$compare_value(", value, ", range.last) >= 0 : Int$compare_value(", value, ", range.last) <= 0 ; ", value, " = Int$plus(", value, ", range.step)) {\n" "\t", body, "\n}", stop, -- cgit v1.2.3