diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2025-09-21 22:55:03 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2025-09-21 22:55:03 -0400 |
| commit | 0d36812c6af951a41caac77d5f312949f3bc521f (patch) | |
| tree | ae0f545805c524ffa467b925687bf70e88e2bc58 /src/typecheck.c | |
| parent | fa7a0ddc0963deb387f0cae7bb22ca968ee9146f (diff) | |
Deprecate binary ops (other than ++) for tables. Instead use proper
methods: t.with(other), t.without(other), t.intersection(other),
t.difference(other)
Diffstat (limited to 'src/typecheck.c')
| -rw-r--r-- | src/typecheck.c | 18 |
1 files changed, 4 insertions, 14 deletions
diff --git a/src/typecheck.c b/src/typecheck.c index 6cd87289..0f720faa 100644 --- a/src/typecheck.c +++ b/src/typecheck.c @@ -1033,6 +1033,10 @@ type_t *get_type(env_t *env, ast_t *ast) { else if (streq(call->name, "set")) return Type(VoidType); else if (streq(call->name, "sorted")) return self_value_t; else if (streq(call->name, "with_fallback")) return self_value_t; + else if (streq(call->name, "without")) return self_value_t; + else if (streq(call->name, "intersection")) return self_value_t; + else if (streq(call->name, "difference")) return self_value_t; + else if (streq(call->name, "with")) return self_value_t; code_err(ast, "There is no '", call->name, "' method for ", type_to_text(self_value_t), " tables"); } default: { @@ -1152,9 +1156,6 @@ type_t *get_type(env_t *env, ast_t *ast) { type_t *lhs_t = get_type(env, binop.lhs); type_t *rhs_t = get_type(env, binop.rhs); - type_t *lhs_val = value_type(lhs_t), *rhs_val = value_type(rhs_t); - if (type_eq(lhs_val, rhs_val) && lhs_val->tag == TableType) return lhs_val; - if (binop.lhs->tag == Int && is_int_type(rhs_t)) return rhs_t; else if (binop.rhs->tag == Int && is_int_type(lhs_t)) return lhs_t; @@ -1198,9 +1199,6 @@ type_t *get_type(env_t *env, ast_t *ast) { type_t *lhs_t = get_type(env, binop.lhs); type_t *rhs_t = get_type(env, binop.rhs); - type_t *lhs_val = value_type(lhs_t), *rhs_val = value_type(rhs_t); - if (type_eq(lhs_val, rhs_val) && lhs_val->tag == TableType) return lhs_val; - if (binop.lhs->tag == Int && is_int_type(rhs_t)) return rhs_t; else if (binop.rhs->tag == Int && is_int_type(lhs_t)) return lhs_t; @@ -1231,9 +1229,6 @@ type_t *get_type(env_t *env, ast_t *ast) { type_t *lhs_t = get_type(env, binop.lhs); type_t *rhs_t = get_type(env, binop.rhs); - type_t *lhs_val = value_type(lhs_t), *rhs_val = value_type(rhs_t); - if (type_eq(lhs_val, rhs_val) && lhs_val->tag == TableType) return lhs_val; - if (binop.lhs->tag == Int && is_int_type(rhs_t)) return rhs_t; else if (binop.rhs->tag == Int && is_int_type(lhs_t)) return lhs_t; @@ -1291,11 +1286,6 @@ type_t *get_type(env_t *env, ast_t *ast) { type_t *lhs_t = get_type(env, binop.lhs); type_t *rhs_t = get_type(env, binop.rhs); - if (ast->tag == Minus) { - type_t *lhs_val = value_type(lhs_t), *rhs_val = value_type(rhs_t); - if (type_eq(lhs_val, rhs_val) && lhs_val->tag == TableType) return lhs_val; - } - if (ast->tag == LeftShift || ast->tag == UnsignedLeftShift || ast->tag == RightShift || ast->tag == UnsignedRightShift) { if (!is_int_type(rhs_t)) |
