diff --git a/src/typechecking.pr b/src/typechecking.pr index f7df534..51b6b03 100644 --- a/src/typechecking.pr +++ b/src/typechecking.pr @@ -3251,9 +3251,11 @@ def implicit_conversion(node: &parser::Node, tpe: &Type, state: &State) { node.kind == parser::NodeKind::PTR and node.value.expr and node.value.expr.kind == parser::NodeKind::IDENTIFIER { node.tpe = tpe - } else if node.tpe and not equals(node.tpe, tpe) and tpe.length != MAX_UINT64 and not state.block_implicit_conv { - // TODO There are other cases where this is too much work - if convert_type_score(tpe, node.tpe, state.module) >= 0 { + } else if not state.block_implicit_conv and node.tpe and not equals(node.tpe, tpe) { + let parameter_t = vector::make(NamedParameter) + parameter_t.push([_tpe = node.tpe] !NamedParameter) + let conv = scope::find_implicit_function(state.scope, parameter_t, tpe, not consteval::is_static) + if conv { let child = parser::copy_node(node) @node = [ kind = parser::NodeKind::CAST, loc = node.loc ] !parser::Node node.value.bin_op = [ left = child ] !parser::NodeBinaryOp