Skip to content

Commit

Permalink
Fix build by being more restrictive
Browse files Browse the repository at this point in the history
  • Loading branch information
Victorious3 committed Mar 5, 2024
1 parent e6a6451 commit cefaf41
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/typechecking.pr
Original file line number Diff line number Diff line change
Expand Up @@ -1469,6 +1469,8 @@ def infer_interface_types(a: &Type, b: &Type, module: &toolchain::Module) -> &Ty
return tpe
}

const IMPLICIT = 15

// TODO This isn't very reliable. Especially when returning bigger numbers than 1, integer conversions can interfere with to reference
// Tries to convert type b to type a
// The return value is -1 if b can't be converted to a
Expand Down Expand Up @@ -1680,7 +1682,7 @@ export def convert_type_score(a: &Type, b: &Type, module: &toolchain::Module, is
if consteval::is_static {
consteval::compile_function(conv, module.scope, parameter_t)
}
return 15
return IMPLICIT
}
}

Expand Down Expand Up @@ -3252,10 +3254,7 @@ def implicit_conversion(node: &parser::Node, tpe: &Type, state: &State) {
node.value.expr and node.value.expr.kind == parser::NodeKind::IDENTIFIER {
node.tpe = tpe
} 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 {
if convert_type_score(tpe, node.tpe, state.module) == IMPLICIT {
let child = parser::copy_node(node)
@node = [ kind = parser::NodeKind::CAST, loc = node.loc ] !parser::Node
node.value.bin_op = [ left = child ] !parser::NodeBinaryOp
Expand Down

0 comments on commit cefaf41

Please sign in to comment.