diff --git a/src/protocol/mod.rs b/src/protocol/mod.rs index 9a41b28c25581af0f1467043b1f9c21082f5e794..28b49cea928f7667630eb86e32814cbb8792360b 100644 --- a/src/protocol/mod.rs +++ b/src/protocol/mod.rs @@ -108,15 +108,17 @@ impl ProtocolDescription { // - check number of arguments by retrieving the one instantiated // monomorph let concrete_type = ConcreteType{ parts: vec![ConcreteTypePart::Component(ast_definition.this, 0)] }; - let mono_index = self.types.get_procedure_monomorph_type_id(&definition_id, &concrete_type.parts).unwrap(); - let mono_type = self.types.get_procedure_monomorph(mono_index); - if mono_type.arg_types.len() != arguments.values.len() { + let procedure_type_id = self.types.get_procedure_monomorph_type_id(&definition_id, &concrete_type.parts).unwrap(); + let procedure_monomorph_index = self.types.get_monomorph(procedure_type_id).variant.as_procedure().monomorph_index; + let monomorph_info = &ast_definition.monomorphs[procedure_monomorph_index as usize]; + if monomorph_info.argument_types.len() != arguments.values.len() { return Err(ComponentCreationError::InvalidNumArguments); } // - for each argument try to make sure the types match for arg_idx in 0..arguments.values.len() { - let expected_type = &mono_type.arg_types[arg_idx]; + let expected_type_id = monomorph_info.argument_types[arg_idx]; + let expected_type = &self.types.get_monomorph(expected_type_id).concrete_type; let provided_value = &arguments.values[arg_idx]; if !self.verify_same_type(expected_type, 0, &arguments, provided_value) { return Err(ComponentCreationError::InvalidArgumentType(arg_idx)); @@ -125,7 +127,7 @@ impl ProtocolDescription { // By now we're sure that all of the arguments are correct. So create // the connector. - return Ok(Prompt::new(&self.types, &self.heap, ast_definition.this, mono_index, arguments)); + return Ok(Prompt::new(&self.types, &self.heap, ast_definition.this, procedure_type_id, arguments)); } fn lookup_module_root(&self, module_name: &[u8]) -> Option {