diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2024-04-28 20:40:56 +0200 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2024-04-28 20:40:56 +0200 |
commit | 89f2dce6f163e20f198667e3eddcc668b10545e6 (patch) | |
tree | 3a16f02ddc3e057989ed32e77358bff4d2a7a594 | |
parent | be5d202e433b2e83f1f16ce8fac26a3ca2631189 (diff) | |
download | rebel-89f2dce6f163e20f198667e3eddcc668b10545e6.tar rebel-89f2dce6f163e20f198667e3eddcc668b10545e6.zip |
rebel-lang: typing: Fix function call type checking to use Coerce::Assign
Apply the same rules to call parameters that are used for variable
assignment.
-rw-r--r-- | crates/rebel-lang/src/typing.rs | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/crates/rebel-lang/src/typing.rs b/crates/rebel-lang/src/typing.rs index 94c84ba..2a0a4ec 100644 --- a/crates/rebel-lang/src/typing.rs +++ b/crates/rebel-lang/src/typing.rs @@ -203,7 +203,7 @@ impl Type { let call_param_type = Self::ast_expr_type(ctx, call_param)?; func_param_type .clone() - .unify(call_param_type, Coerce::Dynamic)?; + .unify(call_param_type, Coerce::Assign)?; } Ok(func.ret) @@ -222,7 +222,7 @@ impl Type { let method = methods.get(method.name).ok_or(TypeError)?; let (self_param, func_params) = method.typ.params.split_first().ok_or(TypeError)?; - self_param.clone().unify(expr_type, Coerce::Dynamic)?; + self_param.clone().unify(expr_type, Coerce::Assign)?; if func_params.len() != params.len() { return Err(TypeError); @@ -232,7 +232,7 @@ impl Type { let call_param_type = Self::ast_expr_type(ctx, call_param)?; func_param_type .clone() - .unify(call_param_type, Coerce::Dynamic)?; + .unify(call_param_type, Coerce::Assign)?; } Ok(method.typ.ret.clone()) |