aboutsummaryrefslogtreecommitdiff
path: root/compile.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2024-09-05 12:44:01 -0400
committerBruce Hill <bruce@bruce-hill.com>2024-09-05 12:44:01 -0400
commite1d0927744cb86ae3636dedc8473c405a0870ac4 (patch)
tree0b877b0fc839ead74d23adeb641882c23accb6fc /compile.c
parent34d98f067eff63d9f10031f6b2b42103d2e3db51 (diff)
Fix 'empty' clause for integer iteration
Diffstat (limited to 'compile.c')
-rw-r--r--compile.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/compile.c b/compile.c
index f5a27ae9..c61caf60 100644
--- a/compile.c
+++ b/compile.c
@@ -1094,7 +1094,7 @@ CORD compile_statement(env_t *env, ast_t *ast)
goto big_n;
- if (for_->empty && mpz_cmp_si(i, 0) == 0) {
+ if (for_->empty && mpz_cmp_si(i, 0) <= 0) {
return compile_statement(env, for_->empty);
} else {
return CORD_all(
@@ -1114,7 +1114,7 @@ CORD compile_statement(env_t *env, ast_t *ast)
return CORD_all(
"{\n"
"Int_t ", n_var, " = ", compile(env, for_->iter), ";\n"
- "if (!I_is_zero(", n_var, ")) {\n"
+ "if (Int$compare_value(", n_var, ", I(0)) > 0) {\n"
"for (Int_t ", i, " = I(1); Int$compare_value(", i, ", ", n_var, ") <= 0; ", i, " = Int$plus(", i, ", I(1))) {\n",
"\t", naked_body,
"}\n"