From 0d36812c6af951a41caac77d5f312949f3bc521f Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Sun, 21 Sep 2025 22:55:03 -0400 Subject: Deprecate binary ops (other than ++) for tables. Instead use proper methods: t.with(other), t.without(other), t.intersection(other), t.difference(other) --- src/compile/binops.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'src/compile/binops.c') diff --git a/src/compile/binops.c b/src/compile/binops.c index 0bff98c0..acf1e031 100644 --- a/src/compile/binops.c +++ b/src/compile/binops.c @@ -160,8 +160,6 @@ Text_t compile_binary_op(env_t *env, ast_t *ast) { return Texts("(", lhs, " + ", rhs, ")"); } case Minus: { - if (overall_t->tag == TableType) - return Texts("Table$minus(", lhs, ", ", rhs, ", ", compile_type_info(overall_t), ")"); if (overall_t->tag != IntType && overall_t->tag != NumType && overall_t->tag != ByteType) code_err(ast, "Math operations are only supported for values of the same " @@ -204,8 +202,6 @@ Text_t compile_binary_op(env_t *env, ast_t *ast) { case And: { if (overall_t->tag == BoolType) return Texts("(", lhs, " && ", rhs, ")"); else if (overall_t->tag == IntType || overall_t->tag == ByteType) return Texts("(", lhs, " & ", rhs, ")"); - else if (overall_t->tag == TableType) - return Texts("Table$and(", lhs, ", ", rhs, ", ", compile_type_info(overall_t), ")"); else code_err(ast, "The 'and' operator isn't supported between ", type_to_text(lhs_t), " and ", type_to_text(rhs_t), " values"); @@ -218,8 +214,6 @@ Text_t compile_binary_op(env_t *env, ast_t *ast) { return Texts("(", lhs, " || ", rhs, ")"); } else if (overall_t->tag == IntType || overall_t->tag == ByteType) { return Texts("(", lhs, " | ", rhs, ")"); - } else if (overall_t->tag == TableType) { - return Texts("Table$or(", lhs, ", ", rhs, ", ", compile_type_info(overall_t), ")"); } else { code_err(ast, "The 'or' operator isn't supported between ", type_to_text(lhs_t), " and ", type_to_text(rhs_t), " values"); @@ -229,8 +223,6 @@ Text_t compile_binary_op(env_t *env, ast_t *ast) { // TODO: support optional values in `xor` expressions if (overall_t->tag == BoolType || overall_t->tag == IntType || overall_t->tag == ByteType) return Texts("(", lhs, " ^ ", rhs, ")"); - else if (overall_t->tag == TableType) - return Texts("Table$xor(", lhs, ", ", rhs, ", ", compile_type_info(overall_t), ")"); else code_err(ast, "The 'xor' operator isn't supported between ", type_to_text(lhs_t), " and ", type_to_text(rhs_t), " values"); @@ -245,6 +237,9 @@ Text_t compile_binary_op(env_t *env, ast_t *ast) { return Texts("List$concat(", lhs, ", ", rhs, ", sizeof(", compile_type(Match(overall_t, ListType)->item_type), "))"); } + case TableType: { + return Texts("Table$with(", lhs, ", ", rhs, ", ", compile_type_info(overall_t), ")"); + } default: code_err(ast, "Concatenation isn't supported between ", type_to_text(lhs_t), " and ", type_to_text(rhs_t), " values"); -- cgit v1.2.3