From b97c0166290f1913a37fb52da61fb62b813c606f Mon Sep 17 00:00:00 2001 From: pca006132 Date: Fri, 18 Mar 2022 16:52:28 +0800 Subject: [PATCH] nac3core: fixed test breakage --- nac3core/src/toplevel/composer.rs | 13 +++++++++++-- nac3core/src/toplevel/type_annotation.rs | 2 ++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/nac3core/src/toplevel/composer.rs b/nac3core/src/toplevel/composer.rs index 5d660533..b3a54432 100644 --- a/nac3core/src/toplevel/composer.rs +++ b/nac3core/src/toplevel/composer.rs @@ -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 } }; diff --git a/nac3core/src/toplevel/type_annotation.rs b/nac3core/src/toplevel/type_annotation.rs index 3d15a760..9fc1f80c 100644 --- a/nac3core/src/toplevel/type_annotation.rs +++ b/nac3core/src/toplevel/type_annotation.rs @@ -105,6 +105,8 @@ pub fn parse_ast_to_type_annotation_kinds( 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))