File tree Expand file tree Collapse file tree 3 files changed +22
-4
lines changed
crates/emmylua_code_analysis/src Expand file tree Collapse file tree 3 files changed +22
-4
lines changed Original file line number Diff line number Diff line change @@ -213,7 +213,7 @@ fn is_valid_member(
213213 match & info. key {
214214 LuaMemberKey :: Expr ( typ) => {
215215 if typ. is_string ( ) {
216- if key_type_set. iter ( ) . any ( |typ| typ. is_string ( ) ) {
216+ if key_type_set. iter ( ) . any ( |typ| typ. is_string ( ) || typ . is_str_tpl_ref ( ) ) {
217217 return Some ( ( ) ) ;
218218 }
219219 } else if typ. is_integer ( ) {
@@ -223,7 +223,7 @@ fn is_valid_member(
223223 }
224224 }
225225 LuaMemberKey :: Name ( _) => {
226- if key_type_set. iter ( ) . any ( |typ| typ. is_string ( ) ) {
226+ if key_type_set. iter ( ) . any ( |typ| typ. is_string ( ) || typ . is_str_tpl_ref ( ) ) {
227227 return Some ( ( ) ) ;
228228 }
229229 }
@@ -304,7 +304,7 @@ fn get_key_types(typ: &LuaType) -> HashSet<LuaType> {
304304 stack. push ( t. clone ( ) ) ;
305305 }
306306 }
307- LuaType :: Ref ( _) => {
307+ LuaType :: StrTplRef ( _ ) | LuaType :: Ref ( _) => {
308308 type_set. insert ( current_type) ;
309309 }
310310 _ => { }
Original file line number Diff line number Diff line change @@ -490,4 +490,22 @@ mod test {
490490 "#
491491 ) ) ;
492492 }
493+
494+ #[ test]
495+ fn test_generic_super ( ) {
496+ let mut ws = VirtualWorkspace :: new ( ) ;
497+ assert ! ( ws. check_code_for(
498+ DiagnosticCode :: UndefinedField ,
499+ r#"
500+ ---@generic Super: string
501+ ---@param super? `Super`
502+ local function declare(super)
503+ ---@type table<string, string>
504+ local config
505+
506+ local superClass = config[super]
507+ end
508+ "#
509+ ) ) ;
510+ }
493511}
Original file line number Diff line number Diff line change @@ -65,7 +65,7 @@ pub fn check_simple_type_compact(
6565 }
6666 }
6767 LuaType :: String | LuaType :: StringConst ( _) => match compact_type {
68- LuaType :: String | LuaType :: StringConst ( _) | LuaType :: DocStringConst ( _) => {
68+ LuaType :: String | LuaType :: StringConst ( _) | LuaType :: DocStringConst ( _) | LuaType :: StrTplRef ( _ ) => {
6969 return Ok ( ( ) ) ;
7070 }
7171 LuaType :: Ref ( _) => {
You can’t perform that action at this time.
0 commit comments