File tree Expand file tree Collapse file tree 2 files changed +30
-2
lines changed
crates/emmylua_code_analysis/src/semantic/type_check Expand file tree Collapse file tree 2 files changed +30
-2
lines changed Original file line number Diff line number Diff line change @@ -68,9 +68,18 @@ pub fn check_table_generic_type_compact(
6868 return Ok ( ( ) ) ;
6969 }
7070 }
71+ LuaType :: Userdata => return Ok ( ( ) ) ,
7172 // maybe support object
7273 // need check later
73- LuaType :: Ref ( _) | LuaType :: Def ( _) | LuaType :: Userdata => return Ok ( ( ) ) ,
74+ LuaType :: Ref ( id) | LuaType :: Def ( id) => {
75+ let owner = LuaMemberOwner :: Type ( id. clone ( ) ) ;
76+ return check_table_generic_compact_member_owner (
77+ db,
78+ source_generic_param,
79+ owner,
80+ check_guard. next_level ( ) ?,
81+ ) ;
82+ }
7483 LuaType :: Union ( union) => {
7584 for union_type in union. into_vec ( ) {
7685 check_table_generic_type_compact (
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_string ( ) {
@@ -150,4 +150,23 @@ mod test {
150150 let ty2 = ws. expr_ty ( "(\" hello\" ):match(\" .*\" )" ) ;
151151 assert ! ( ws. check_type( & ty, & ty2) ) ;
152152 }
153+
154+ #[ test]
155+ fn test_issue_634 ( ) {
156+ let mut ws = VirtualWorkspace :: new ( ) ;
157+
158+ assert ! ( !ws. check_code_for(
159+ DiagnosticCode :: ParamTypeNotMatch ,
160+ r#"
161+ --- @class A
162+ --- @field a integer
163+
164+ --- @param x table<integer,string>
165+ local function foo(x) end
166+
167+ local y --- @type A
168+ foo(y) -- should error
169+ "#
170+ ) ) ;
171+ }
153172}
You can’t perform that action at this time.
0 commit comments