nac3core: fixed test breakage

This commit is contained in:
pca006132 2022-03-18 16:52:28 +08:00
parent 14a5c7981e
commit b97c016629
2 changed files with 13 additions and 2 deletions

View File

@ -1193,9 +1193,18 @@ impl TopLevelComposer {
unreachable!("must be type var annotation");
}
}
get_type_from_type_annotation_kinds(temp_def_list, unifier, primitives, &annotation)?
let dummy_return_type = unifier.get_dummy_var().0;
type_var_to_concrete_def.insert(dummy_return_type, annotation.clone());
dummy_return_type
} else {
primitives.none
// if do not have return annotation, return none
// for uniform handling, still use type annoatation
let dummy_return_type = unifier.get_dummy_var().0;
type_var_to_concrete_def.insert(
dummy_return_type,
TypeAnnotation::Primitive(primitives.none),
);
dummy_return_type
}
};

View File

@ -105,6 +105,8 @@ pub fn parse_ast_to_type_annotation_kinds<T>(
Ok(TypeAnnotation::CustomClass { id: obj_id, params: vec![] })
} else if let Ok(ty) = resolver.get_symbol_type(unifier, top_level_defs, primitives, *id) {
if let TypeEnum::TVar { .. } = unifier.get_ty(ty).as_ref() {
let var = unifier.get_fresh_var(Some(*id), Some(expr.location)).0;
unifier.unify(var, ty).unwrap();
Ok(TypeAnnotation::TypeVar(ty))
} else {
Err(format!("`{}` is not a valid type annotation (at {})", id, expr.location))