File tree Expand file tree Collapse file tree
crates/emmylua_code_analysis/src/compilation/test Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -57,4 +57,21 @@ mod test {
5757 "Union(LuaUnionType { types: [Nil, IntegerConst(2)] })"
5858 ) ;
5959 }
60+
61+ #[ test]
62+ fn test_issue_258 ( ) {
63+ let mut ws = VirtualWorkspace :: new ( ) ;
64+
65+ ws. def (
66+ r#"
67+ local a --- @type string|nil
68+ local b --- @type string|nil
69+ c = a or b
70+ "# ,
71+ ) ;
72+
73+ let c = ws. expr_ty ( "c" ) ;
74+ let c_desc = ws. humanize_type ( c) ;
75+ assert_eq ! ( c_desc, "(string|nil)" ) ;
76+ }
6077}
Original file line number Diff line number Diff line change 300300 "#
301301 ) ) ;
302302 }
303+
304+ #[ test]
305+ fn test_issue_266 ( ) {
306+ let mut ws = VirtualWorkspace :: new ( ) ;
307+
308+ assert ! ( ws. check_code_for( DiagnosticCode :: AssignTypeMismatch , r#"
309+ --- @return string
310+ function baz() end
311+
312+ local a
313+ a = baz() -- a has type nil but should be string
314+ d = a
315+ "# ) ) ;
316+
317+ let d = ws. expr_ty ( "d" ) ;
318+ let d_desc = ws. humanize_type ( d) ;
319+ assert_eq ! ( d_desc, "string" ) ;
320+ }
321+
303322}
You can’t perform that action at this time.
0 commit comments