Fix unification of arg types in unions where one side has nil(s)

This commit is contained in:
Filip Tibell 2023-02-22 12:40:48 +01:00
parent a96745c292
commit 41ba23d7ab
No known key found for this signature in database
2 changed files with 15 additions and 1 deletions

View file

@ -142,6 +142,7 @@ impl DefinitionsParser {
results.push(self.convert_parser_item_into_doc_item(top_level_item.clone())); results.push(self.convert_parser_item_into_doc_item(top_level_item.clone()));
} }
self.found_top_level_items = BTreeMap::new(); self.found_top_level_items = BTreeMap::new();
self.found_top_level_types = HashMap::new();
self.found_top_level_declares = Vec::new(); self.found_top_level_declares = Vec::new();
Ok(results) Ok(results)
} }

View file

@ -247,6 +247,16 @@ impl TypeInfoExt for TypeInfo {
} }
} }
fn make_empty_type_argument() -> TypeArgument {
TypeArgument::new(TypeInfo::Basic(TokenReference::new(
vec![],
Token::new(TokenType::Symbol {
symbol: Symbol::Nil,
}),
vec![],
)))
}
fn merge_type_arguments(left: TypeArgument, right: TypeArgument) -> TypeArgument { fn merge_type_arguments(left: TypeArgument, right: TypeArgument) -> TypeArgument {
TypeArgument::new(TypeInfo::Union { TypeArgument::new(TypeInfo::Union {
left: Box::new(left.type_info().clone()), left: Box::new(left.type_info().clone()),
@ -270,7 +280,10 @@ fn merge_type_argument_vecs(
if let Some(existing) = existing.get(index) { if let Some(existing) = existing.get(index) {
result.push(merge_type_arguments(existing.clone(), argument.clone())); result.push(merge_type_arguments(existing.clone(), argument.clone()));
} else { } else {
result.push(argument.clone()); result.push(merge_type_arguments(
make_empty_type_argument(),
argument.clone(),
));
} }
} }
result result