Allow type inference to go through value aliasing

This commit is contained in:
Keith Yeung
2017-03-14 10:25:30 -07:00
committed by Jakob Stoklund Olesen
parent e1d17b2acf
commit c6f8bfff0b

View File

@@ -1299,13 +1299,20 @@ impl<'a> Parser<'a> {
let ctrl_src_value = inst_data.typevar_operand(&ctx.function.dfg.value_lists) let ctrl_src_value = inst_data.typevar_operand(&ctx.function.dfg.value_lists)
.expect("Constraints <-> Format inconsistency"); .expect("Constraints <-> Format inconsistency");
ctx.function.dfg.value_type(match ctx.map.get_value(ctrl_src_value) { ctx.function.dfg.value_type(match ctx.map.get_value(ctrl_src_value) {
Some(v) => v, Some(v) => v,
None => { None => {
return err!(self.loc, if let Some(v) = ctx.aliases
"cannot determine type of operand {}", .get(&ctrl_src_value)
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() { } else if constraints.is_polymorphic() {
// This opcode does not support type inference, so the explicit type variable // This opcode does not support type inference, so the explicit type variable
// is required. // is required.