diff --git a/nac3core/src/toplevel/helper.rs b/nac3core/src/toplevel/helper.rs index 73325ad5b..2912e3e75 100644 --- a/nac3core/src/toplevel/helper.rs +++ b/nac3core/src/toplevel/helper.rs @@ -43,7 +43,12 @@ impl TopLevelDef { "Function {{\nname: {:?},\nsig: {:?},\nvar_id: {:?}\n}}", name, unifier.stringify(*signature, obj_to_name, var_to_name), - var_id + { + // NOTE: preserve the order for debug output and test + let mut r = var_id.clone(); + r.sort_unstable(); + r + } ), TopLevelDef::Initializer { class_id } => format!("Initializer {{ {:?} }}", class_id), } diff --git a/nac3core/src/toplevel/mod.rs b/nac3core/src/toplevel/mod.rs index d5e705823..ce3959825 100644 --- a/nac3core/src/toplevel/mod.rs +++ b/nac3core/src/toplevel/mod.rs @@ -588,7 +588,7 @@ impl TopLevelComposer { } println!("type_var_to_concrete_def3: {:?}\n", type_var_to_concrete_def); - + // unification of previously assigned typevar for (ty, def) in type_var_to_concrete_def { println!( @@ -864,8 +864,7 @@ impl TopLevelComposer { )? }; // find type vars within this method parameter type annotation - let type_vars_within = - get_type_var_contained_in_type_annotation(&type_ann); + let type_vars_within = get_type_var_contained_in_type_annotation(&type_ann); // handle the class type var and the method type var for type_var_within in type_vars_within { if let TypeAnnotation::TypeVarKind(ty) = type_var_within { @@ -987,7 +986,7 @@ impl TopLevelComposer { unreachable!("must be type var annotation"); } } - + // TODO: allow class have field which type refers to Self type? type_var_to_concrete_def .insert(dummy_field_type, annotation); diff --git a/nac3core/src/toplevel/test.rs b/nac3core/src/toplevel/test.rs index 5de448384..a3bdf1a43 100644 --- a/nac3core/src/toplevel/test.rs +++ b/nac3core/src/toplevel/test.rs @@ -342,7 +342,7 @@ fn test_simple_class_analyze(source: Vec<&str>, res: Vec<&str>) { let tvar_v = composer .unifier .get_fresh_var_with_range(&[composer.primitives_ty.bool, composer.primitives_ty.int32]); - + println!("t: {}, {:?}", tvar_t.1, tvar_t.0); println!("v: {}, {:?}\n", tvar_v.1, tvar_v.0);