Skip to content

Commit 019c08f

Browse files
committed
change union index
Fix #796
1 parent 54d6d88 commit 019c08f

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -664,10 +664,10 @@ fn infer_union_member(
664664
index_expr.clone(),
665665
&infer_guard.fork(),
666666
);
667-
if let Ok(typ) = result
668-
&& !typ.is_nil()
669-
{
667+
if let Ok(typ) = result {
670668
member_types.push(typ);
669+
} else {
670+
member_types.push(LuaType::Nil);
671671
}
672672
}
673673

crates/emmylua_ls/src/handlers/test/code_actions_test.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,16 @@ mod tests {
2222
local _a = A:get(1):get(2):get(3)
2323
"#,
2424
vec![
25+
VirtualCodeAction {
26+
title: "Disable current line diagnostic (need-check-nil)".to_string()
27+
},
28+
VirtualCodeAction {
29+
title: "Disable all diagnostics in current file (need-check-nil)".to_string()
30+
},
31+
VirtualCodeAction {
32+
title:
33+
"Disable all diagnostics in current project (need-check-nil)".to_string()
34+
},
2535
VirtualCodeAction {
2636
title: "use cast to remove nil".to_string()
2737
},
@@ -35,6 +45,16 @@ mod tests {
3545
title:
3646
"Disable all diagnostics in current project (need-check-nil)".to_string()
3747
},
48+
VirtualCodeAction {
49+
title: "Disable current line diagnostic (need-check-nil)".to_string()
50+
},
51+
VirtualCodeAction {
52+
title: "Disable all diagnostics in current file (need-check-nil)".to_string()
53+
},
54+
VirtualCodeAction {
55+
title:
56+
"Disable all diagnostics in current project (need-check-nil)".to_string()
57+
},
3858
VirtualCodeAction {
3959
title: "use cast to remove nil".to_string()
4060
},

0 commit comments

Comments
 (0)