Skip to content

Commit 117e344

Browse files
committed
Fix or nil
1 parent 26e74e2 commit 117e344

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@ pub fn special_or_rule(
2323
}
2424
}
2525
LuaExpr::LiteralExpr(_) => {
26-
if check_type_compact(db, &left_type, &right_type).is_ok() {
27-
return Some(TypeOps::Remove.apply(&left_type, &LuaType::Nil));
26+
if !right_type.is_nil() {
27+
if check_type_compact(db, &left_type, &right_type).is_ok() {
28+
return Some(TypeOps::Remove.apply(&left_type, &LuaType::Nil));
29+
}
2830
}
2931
}
3032

@@ -42,6 +44,5 @@ pub fn infer_binary_expr_or(left: LuaType, right: LuaType) -> InferResult {
4244
}
4345

4446
// if check_type_compact(db, source, compact_type)
45-
4647
Ok(TypeOps::Union.apply(&TypeOps::Remove.apply(&left, &LuaType::Nil), &right))
4748
}

0 commit comments

Comments
 (0)