Never use the first vararg as typevar operand

If an instruction only takes varargs as values, it may have no arguments
at all.
This commit is contained in:
bjorn3
2021-10-31 18:47:13 +01:00
parent 795e381be4
commit 74261ccd79
2 changed files with 16 additions and 18 deletions

View File

@@ -133,7 +133,7 @@ impl InstructionFormatBuilder {
pub fn typevar_operand(mut self, operand_index: usize) -> Self {
assert!(self.typevar_operand.is_none());
assert!(self.has_value_list || operand_index < self.num_value_operands);
assert!(operand_index < self.num_value_operands);
self.typevar_operand = Some(operand_index);
self
}
@@ -141,7 +141,7 @@ impl InstructionFormatBuilder {
pub fn build(self) -> Rc<InstructionFormat> {
let typevar_operand = if self.typevar_operand.is_some() {
self.typevar_operand
} else if self.has_value_list || self.num_value_operands > 0 {
} else if self.num_value_operands > 0 {
// Default to the first value operand, if there's one.
Some(0)
} else {