@@ -106,6 +106,26 @@ pub fn multi_param_tpl_pattern_match_multi_return(
106106 Ok ( ( ) )
107107}
108108
109+ fn get_str_tpl_infer_type ( name : & str ) -> LuaType {
110+ match name {
111+ "unknown" => LuaType :: Unknown ,
112+ "never" => LuaType :: Never ,
113+ "nil" | "void" => LuaType :: Nil ,
114+ "any" => LuaType :: Any ,
115+ "userdata" => LuaType :: Userdata ,
116+ "thread" => LuaType :: Thread ,
117+ "boolean" | "bool" => LuaType :: Boolean ,
118+ "string" => LuaType :: String ,
119+ "integer" | "int" => LuaType :: Integer ,
120+ "number" => LuaType :: Number ,
121+ "io" => LuaType :: Io ,
122+ "self" => LuaType :: SelfInfer ,
123+ "global" => LuaType :: Global ,
124+ "function" => LuaType :: Function ,
125+ _ => LuaType :: Ref ( LuaTypeDeclId :: global ( & name) ) ,
126+ }
127+ }
128+
109129pub fn tpl_pattern_match (
110130 context : & mut TplContext ,
111131 pattern : & LuaType ,
@@ -138,7 +158,7 @@ pub fn tpl_pattern_match(
138158 let type_name = SmolStr :: new ( format ! ( "{}{}{}" , prefix, s, suffix) ) ;
139159 context. substitutor . insert_type (
140160 str_tpl. get_tpl_id ( ) ,
141- LuaType :: Ref ( LuaTypeDeclId :: global ( & type_name) ) ,
161+ get_str_tpl_infer_type ( & type_name) ,
142162 true ,
143163 ) ;
144164 }
0 commit comments