aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorPhilip Herron <philip.herron@embecosm.com>2022-05-24 15:43:53 +0100
committerPhilip Herron <philip.herron@embecosm.com>2022-05-25 11:54:00 +0100
commitd01ae2ab56be6b515a863184baad496c50363fe6 (patch)
tree851d3e1db5b2a050e364439ab5aaf0ca153d1d88 /gcc
parentd09b135116f2bd56fbab054a9a0122cc6b59e06e (diff)
downloadgcc-d01ae2ab56be6b515a863184baad496c50363fe6.zip
gcc-d01ae2ab56be6b515a863184baad496c50363fe6.tar.gz
gcc-d01ae2ab56be6b515a863184baad496c50363fe6.tar.bz2
Remove old hack to handle type inferencing in untyped decalred bindings
In the case where you define let a; with no type to then use this binding and let type inferencing infer the type we used this code to implicitly generate a new type binding to the resolved node id of the the lvalue. This was very dangerous and was always meant to be a stop gap untill we supported more of type inferencing. The issue here was that we were badly overriting a function types within the type-context which hits an ICE in the method resolution code which is expecting function TyTy's within in order to match methods correctly. Fixes #1274 #1273
Diffstat (limited to 'gcc')
-rw-r--r--gcc/rust/typecheck/rust-hir-type-check-expr.h41
1 files changed, 1 insertions, 40 deletions
diff --git a/gcc/rust/typecheck/rust-hir-type-check-expr.h b/gcc/rust/typecheck/rust-hir-type-check-expr.h
index b20a048..8145c5a 100644
--- a/gcc/rust/typecheck/rust-hir-type-check-expr.h
+++ b/gcc/rust/typecheck/rust-hir-type-check-expr.h
@@ -384,46 +384,7 @@ public:
auto lhs = TypeCheckExpr::Resolve (expr.get_lhs (), false);
auto rhs = TypeCheckExpr::Resolve (expr.get_rhs (), false);
- auto result = lhs->coerce (rhs);
- if (result->get_kind () == TyTy::TypeKind::ERROR)
- return;
-
- // in the case of declare first for an ADT Type:
- //
- // let a;
- // a = Foo{..}
- // let b = a.field;
- //
- // The lhs will have a TyTy of INFER and so when the declaration is
- // referenced it will still have an unknown type so we will fail to resolve
- // FieldAccessExpr
-
- NodeId ast_node_id = expr.get_lhs ()->get_mappings ().get_nodeid ();
- NodeId ref_node_id;
- if (!resolver->lookup_resolved_name (ast_node_id, &ref_node_id))
- return;
-
- Definition def;
- if (!resolver->lookup_definition (ref_node_id, &def))
- {
- rust_error_at (expr.get_locus (),
- "assignment infer - unknown reference");
- return;
- }
-
- HirId ref;
- if (!mappings->lookup_node_to_hir (expr.get_mappings ().get_crate_num (),
- def.parent, &ref))
- {
- rust_error_at (expr.get_locus (),
- "assignment infer - reverse lookup failure");
- return;
- }
-
- context->insert_type (
- Analysis::NodeMapping (expr.get_lhs ()->get_mappings ().get_crate_num (),
- ref_node_id, ref, UNKNOWN_LOCAL_DEFID),
- result->clone ());
+ lhs->coerce (rhs);
}
void visit (HIR::CompoundAssignmentExpr &expr) override