File tree Expand file tree Collapse file tree
crates/emmylua_code_analysis/src Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -213,13 +213,29 @@ mod tests {
213213 assert ! ( ws. check_code_for(
214214 DiagnosticCode :: ReturnTypeMismatch ,
215215 r#"
216- ---@return string?
217- local function a()
218- ---@type int?
219- local ccc
220- return ccc and a() or nil
221- end
216+ ---@return string?
217+ local function a()
218+ ---@type int?
219+ local ccc
220+ return ccc and a() or nil
221+ end
222+ "#
223+ ) ) ;
224+ }
225+
226+ #[ test]
227+ fn test_2 ( ) {
228+ let mut ws = VirtualWorkspace :: new ( ) ;
222229
230+ assert ! ( ws. check_code_for(
231+ DiagnosticCode :: ReturnTypeMismatch ,
232+ r#"
233+ ---@return any[]
234+ local function a()
235+ ---@type table|table<any, any>
236+ local ccc
237+ return ccc
238+ end
223239 "#
224240 ) ) ;
225241 }
Original file line number Diff line number Diff line change @@ -62,6 +62,24 @@ pub fn check_complex_type_compact(
6262 ) ;
6363 }
6464 LuaType :: Table => return Ok ( ( ) ) ,
65+ LuaType :: TableGeneric ( compact_types) => {
66+ if compact_types. len ( ) == 2 {
67+ for typ in compact_types. iter ( ) {
68+ if check_general_type_compact (
69+ db,
70+ source_base,
71+ typ,
72+ check_guard. next_level ( ) ?,
73+ )
74+ . is_err ( )
75+ {
76+ return Err ( TypeCheckFailReason :: TypeNotMatch ) ;
77+ }
78+ }
79+
80+ return Ok ( ( ) ) ;
81+ }
82+ }
6583 _ => { }
6684 } ,
6785 LuaType :: Tuple ( tuple) => {
You can’t perform that action at this time.
0 commit comments