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 11#[ cfg( test) ]
22mod test {
3- use crate :: VirtualWorkspace ;
3+ use crate :: { DiagnosticCode , VirtualWorkspace } ;
44
55 #[ test]
66 fn test_flow ( ) {
@@ -26,4 +26,24 @@ mod test {
2626 let expected = ws. ty ( "string[]" ) ;
2727 assert_eq ! ( ty, expected) ;
2828 }
29+
30+ #[ test]
31+ fn test_issue_265 ( ) {
32+ let mut ws = VirtualWorkspace :: new ( ) ;
33+
34+ assert ! ( ws. check_code_for(
35+ DiagnosticCode :: ReturnTypeMismatch ,
36+ r#"
37+ local function bar()
38+ return ''
39+ end
40+
41+ --- @return integer
42+ function foo()
43+ return bar() --[[@as integer]]
44+ end
45+
46+ "# ,
47+ ) ) ;
48+ }
2949}
Original file line number Diff line number Diff line change @@ -305,18 +305,20 @@ end
305305 fn test_issue_266 ( ) {
306306 let mut ws = VirtualWorkspace :: new ( ) ;
307307
308- assert ! ( ws. check_code_for( DiagnosticCode :: AssignTypeMismatch , r#"
308+ assert ! ( ws. check_code_for(
309+ DiagnosticCode :: AssignTypeMismatch ,
310+ r#"
309311 --- @return string
310312 function baz() end
311313
312314 local a
313315 a = baz() -- a has type nil but should be string
314316 d = a
315- "# ) ) ;
317+ "#
318+ ) ) ;
316319
317320 let d = ws. expr_ty ( "d" ) ;
318321 let d_desc = ws. humanize_type ( d) ;
319322 assert_eq ! ( d_desc, "string" ) ;
320323 }
321-
322324}
You can’t perform that action at this time.
0 commit comments