diff --git a/tests/r7rs-tests.scm b/tests/r7rs-tests.scm index 0f5477dd..2130031b 100644 --- a/tests/r7rs-tests.scm +++ b/tests/r7rs-tests.scm @@ -611,6 +611,7 @@ (test #f (<= 1 2 1)) (test #t (>= 2 1 1)) (test #f (>= 1 2 1)) +(test '(#t #f) (list (<= 1 1 2) (<= 2 1 3))) ;; From R7RS 6.2.6 Numerical operations: ;; diff --git a/vm.c b/vm.c index d573c8b8..cd06ce42 100644 --- a/vm.c +++ b/vm.c @@ -359,6 +359,8 @@ static void generate_opcode_app (sexp ctx, sexp app) { sexp_emit(ctx, sexp_opcode_code(op)); break; case SEXP_OPC_ARITHMETIC_CMP: + /* With [, x] on the stack, and x boolean, */ + /* AND is equivalent to ROT+DROP. Note one AND for every STACK_REF. */ if (num_args > 2) { sexp_emit(ctx, SEXP_OP_STACK_REF); sexp_emit_word(ctx, 2); @@ -375,6 +377,7 @@ static void generate_opcode_app (sexp ctx, sexp app) { sexp_emit(ctx, SEXP_OP_AND); sexp_emit(ctx, SEXP_OP_AND); } + sexp_emit(ctx, SEXP_OP_AND); } else sexp_emit(ctx, sexp_opcode_code(op)); break;