Skip to content

Commit babc29a

Browse files
committed
fix test
1 parent e83a3de commit babc29a

1 file changed

Lines changed: 6 additions & 8 deletions

File tree

crates/emmylua_code_analysis/src/semantic/infer/infer_binary.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
use std::collections::HashSet;
2-
31
use emmylua_parser::{BinaryOperator, LuaBinaryExpr};
42
use smol_str::SmolStr;
53

@@ -63,7 +61,7 @@ fn infer_binary_expr_type(
6361
}
6462

6563
fn infer_union(db: &DbIndex, u: &LuaUnionType, right: &LuaType, op: BinaryOperator) -> InferResult {
66-
let mut unique_union_types = HashSet::new();
64+
let mut unique_union_types = Vec::new();
6765

6866
for ty in u.get_types() {
6967
let inferred_ty = infer_binary_expr_type(db, ty.clone(), right.clone(), op)?;
@@ -73,13 +71,11 @@ fn infer_union(db: &DbIndex, u: &LuaUnionType, right: &LuaType, op: BinaryOperat
7371
match unique_union_types.len() {
7472
0 => Some(LuaType::Unknown),
7573
1 => Some(unique_union_types.into_iter().next().unwrap()),
76-
_ => Some(LuaType::Union(
77-
LuaUnionType::new(unique_union_types.into_iter().collect()).into(),
78-
)),
74+
_ => Some(LuaType::Union(LuaUnionType::new(unique_union_types).into())),
7975
}
8076
}
8177

82-
fn flatten_and_insert(ty: LuaType, unique_union_types: &mut HashSet<LuaType>) {
78+
fn flatten_and_insert(ty: LuaType, unique_union_types: &mut Vec<LuaType>) {
8379
let mut stack = vec![ty];
8480
while let Some(current_ty) = stack.pop() {
8581
match current_ty {
@@ -89,7 +85,9 @@ fn flatten_and_insert(ty: LuaType, unique_union_types: &mut HashSet<LuaType>) {
8985
}
9086
}
9187
_ => {
92-
unique_union_types.insert(current_ty);
88+
if !unique_union_types.contains(&current_ty) {
89+
unique_union_types.push(current_ty);
90+
}
9391
}
9492
}
9593
}

0 commit comments

Comments
 (0)