File tree Expand file tree Collapse file tree 2 files changed +20
-4
lines changed
crates/emmylua_code_analysis/src Expand file tree Collapse file tree 2 files changed +20
-4
lines changed Original file line number Diff line number Diff line change @@ -47,4 +47,20 @@ mod tests {
47
47
) ;
48
48
assert_eq ! ( ty, expected_ty) ;
49
49
}
50
+
51
+ #[ test]
52
+ fn test_issue_595 ( ) {
53
+ let mut ws = VirtualWorkspace :: new ( ) ;
54
+ ws. check_code_for (
55
+ DiagnosticCode :: AssignTypeMismatch ,
56
+ r#"
57
+ local ret --- @type [integer?]
58
+ local h = ret[#ret] -- type is integer??
59
+ if h then
60
+ --- @type integer
61
+ local _ = h
62
+ end
63
+ "# ,
64
+ ) ;
65
+ }
50
66
}
Original file line number Diff line number Diff line change @@ -451,12 +451,12 @@ fn infer_tuple_member(
451
451
} ;
452
452
}
453
453
LuaType :: Integer => {
454
- let mut result = Vec :: new ( ) ;
454
+ let mut result = LuaType :: Unknown ;
455
455
for typ in tuple_type. get_types ( ) {
456
- result. push ( typ. clone ( ) ) ;
456
+ result = TypeOps :: Union . apply ( db , & result , typ) ;
457
457
}
458
- result. push ( LuaType :: Nil ) ;
459
- return Ok ( LuaType :: Union ( LuaUnionType :: from_vec ( result) . into ( ) ) ) ;
458
+ result = TypeOps :: Union . apply ( db , & result , & LuaType :: Nil ) ;
459
+ return Ok ( result) ;
460
460
}
461
461
_ => { }
462
462
} ,
You can’t perform that action at this time.
0 commit comments