Skip to content

Commit

Permalink
Fix superflous casts destroying the reported type of expressions
Browse files Browse the repository at this point in the history
  • Loading branch information
Victorious3 committed Mar 5, 2024
1 parent bee13d0 commit e6a6451
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/typechecking.pr
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e6a6451

Please sign in to comment.