From f0750d7091a7f9014d4327cc13f4625af2da2500 Mon Sep 17 00:00:00 2001 From: Philip Herron Date: Thu, 18 Mar 2021 15:18:21 +0000 Subject: Fix type unification for Inference Variables and return types When we resolve the type of an expression such as a LiteralExpr with HIR id 10, but is the final expression in a BlockExpr of HirId 11. The same type is infered for the entire BlockExpr as well as the final Expr but we override the reference id on the TyTy::Type. This means if there is a change in reference id the old ID must be added to the combined reference chain for type inference to take place. Fixes #293 --- gcc/rust/typecheck/rust-tyty.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'gcc/rust') diff --git a/gcc/rust/typecheck/rust-tyty.h b/gcc/rust/typecheck/rust-tyty.h index 9fe7417..2d97a0b 100644 --- a/gcc/rust/typecheck/rust-tyty.h +++ b/gcc/rust/typecheck/rust-tyty.h @@ -57,7 +57,12 @@ public: HirId get_ref () const { return ref; } - void set_ref (HirId id) { ref = id; } + void set_ref (HirId id) + { + if (id != ref) + append_reference (ref); + ref = id; + } HirId get_ty_ref () const { return ty_ref; } -- cgit v1.1