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))