summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2024-04-28 20:40:56 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2024-04-28 20:40:56 +0200
commit89f2dce6f163e20f198667e3eddcc668b10545e6 (patch)
tree3a16f02ddc3e057989ed32e77358bff4d2a7a594
parentbe5d202e433b2e83f1f16ce8fac26a3ca2631189 (diff)
downloadrebel-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.rs6
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())