Skip to content

Commit d04abef

Browse files
committed
Fix test error
1 parent 6b7938f commit d04abef

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

crates/emmylua_code_analysis/src/semantic/generic/instantiate_type_generic.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -176,16 +176,19 @@ fn instantiate_object(
176176

177177
fn instantiate_union(db: &DbIndex, union: &LuaUnionType, substitutor: &TypeSubstitutor) -> LuaType {
178178
let types = union.into_vec();
179-
let mut new_types = HashSet::new();
179+
let mut new_type_set = HashSet::new();
180+
let mut old_sorted_types = Vec::new();
180181
for t in types {
181182
let t = instantiate_type_generic(db, &t, substitutor);
182-
new_types.insert(t);
183+
if new_type_set.insert(t.clone()) {
184+
old_sorted_types.push(t);
185+
}
183186
}
184187

185-
match new_types.len() {
188+
match old_sorted_types.len() {
186189
0 => LuaType::Unknown,
187-
1 => new_types.iter().next().unwrap().clone(),
188-
_ => LuaType::Union(LuaUnionType::from_set(new_types).into()),
190+
1 => old_sorted_types[0].clone(),
191+
_ => LuaType::Union(LuaUnionType::from_vec(old_sorted_types).into()),
189192
}
190193
}
191194

crates/emmylua_ls/src/handlers/test_lib/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,10 @@ impl ProviderVirtualWorkspace {
147147
};
148148
// dbg!(&value);
149149
if value != expect.value {
150+
eprintln!(
151+
"Hover content does not match expected value left: {value},\nright: {}",
152+
expect.value
153+
);
150154
return false;
151155
}
152156

0 commit comments

Comments
 (0)