From c941b9a3325228eba404455afea7ccea0da45095 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Sun, 21 Sep 2025 17:44:08 -0400 Subject: Fix tests --- src/compile/assertions.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src/compile/assertions.c') diff --git a/src/compile/assertions.c b/src/compile/assertions.c index 3ea6bf1e..5746b21e 100644 --- a/src/compile/assertions.c +++ b/src/compile/assertions.c @@ -4,7 +4,6 @@ #include "../config.h" #include "../environment.h" #include "../stdlib/datatypes.h" -#include "../stdlib/print.h" #include "../stdlib/text.h" #include "../stdlib/util.h" #include "../typecheck.h" @@ -17,7 +16,7 @@ Text_t compile_assertion(env_t *env, ast_t *ast) { const char *failure = NULL; switch (expr->tag) { case And: { - DeclareMatch(and_, ast, And); + DeclareMatch(and_, expr, And); return Texts(compile_statement(env, WrapAST(ast, Assert, .expr = and_->lhs, .message = message)), compile_statement(env, WrapAST(ast, Assert, .expr = and_->rhs, .message = message))); } @@ -32,13 +31,13 @@ Text_t compile_assertion(env_t *env, ast_t *ast) { assert_comparison: { binary_operands_t cmp = BINARY_OPERANDS(expr); type_t *lhs_t = get_type(env, cmp.lhs); - type_t *rhs_t = get_type(env, cmp.rhs); + type_t *rhs_t = get_type(with_enum_scope(env, lhs_t), cmp.rhs); type_t *operand_t; if (cmp.lhs->tag == Int && is_numeric_type(rhs_t)) { operand_t = rhs_t; } else if (cmp.rhs->tag == Int && is_numeric_type(lhs_t)) { operand_t = lhs_t; - } else if (can_compile_to_type(env, cmp.rhs, lhs_t)) { + } else if (can_compile_to_type(with_enum_scope(env, lhs_t), cmp.rhs, lhs_t)) { operand_t = lhs_t; } else if (can_compile_to_type(env, cmp.lhs, rhs_t)) { operand_t = rhs_t; -- cgit v1.2.3