diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2025-04-05 00:58:45 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2025-04-05 00:58:45 -0400 |
| commit | 355ad9532163f9513c01aa59333aed5363386022 (patch) | |
| tree | 4e7204809e489d9d014dc189065e62f7e1670a24 /src/compile.c | |
| parent | f0b1a0f227cb7545af9ec27fbb4742b8c2c03bcd (diff) | |
Fix remaining metamethods
Diffstat (limited to 'src/compile.c')
| -rw-r--r-- | src/compile.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/compile.c b/src/compile.c index 33621bd5..05cc7bcd 100644 --- a/src/compile.c +++ b/src/compile.c @@ -606,6 +606,16 @@ static CORD compile_binary_op(env_t *env, ast_t *ast) return CORD_all(b->code, "(", compile_arguments(env, ast, fn->args, args), ")"); } } + } else if ((ast->tag == Divide || ast->tag == Mod || ast->tag == Mod1) && is_numeric_type(rhs_t)) { + b = get_namespace_binding(env, binop.lhs, binop_method_name(ast->tag)); + if (b && b->type->tag == FunctionType) { + auto fn = Match(b->type, FunctionType); + if (type_eq(fn->ret, lhs_t)) { + arg_ast_t *args = new(arg_ast_t, .value=binop.lhs, .next=new(arg_ast_t, .value=binop.rhs)); + if (is_valid_call(env, fn->args, args, true)) + return CORD_all(b->code, "(", compile_arguments(env, ast, fn->args, args), ")"); + } + } } if (ast->tag == Or && lhs_t->tag == OptionalType) { |
