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 {
4747 ) ;
4848 assert_eq ! ( ty, expected_ty) ;
4949 }
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+ }
5066}
Original file line number Diff line number Diff line change @@ -451,12 +451,12 @@ fn infer_tuple_member(
451451 } ;
452452 }
453453 LuaType :: Integer => {
454- let mut result = Vec :: new ( ) ;
454+ let mut result = LuaType :: Unknown ;
455455 for typ in tuple_type. get_types ( ) {
456- result. push ( typ. clone ( ) ) ;
456+ result = TypeOps :: Union . apply ( db , & result , typ) ;
457457 }
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) ;
460460 }
461461 _ => { }
462462 } ,
You can’t perform that action at this time.
0 commit comments