From f18eddc9eddf87de7f1fde9b4245b4f801930613 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Tue, 14 Mar 2017 10:25:30 -0700 Subject: [PATCH] Allow type inference to go through value aliasing --- lib/reader/src/parser.rs | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/lib/reader/src/parser.rs b/lib/reader/src/parser.rs index 21de8bcda7..9f29e54090 100644 --- a/lib/reader/src/parser.rs +++ b/lib/reader/src/parser.rs @@ -1299,13 +1299,20 @@ impl<'a> Parser<'a> { let ctrl_src_value = inst_data.typevar_operand(&ctx.function.dfg.value_lists) .expect("Constraints <-> Format inconsistency"); ctx.function.dfg.value_type(match ctx.map.get_value(ctrl_src_value) { - Some(v) => v, - None => { - return err!(self.loc, - "cannot determine type of operand {}", - ctrl_src_value); - } - }) + Some(v) => v, + None => { + if let Some(v) = ctx.aliases + .get(&ctrl_src_value) + .and_then(|&(aliased, _)| ctx.map.get_value(aliased)) + { + v + } else { + return err!(self.loc, + "cannot determine type of operand {}", + ctrl_src_value); + } + } + }) } else if constraints.is_polymorphic() { // This opcode does not support type inference, so the explicit type variable // is required.