Skip to content

Commit 114f8b8

Browse files
committed
fix test
1 parent 91d2c31 commit 114f8b8

2 files changed

Lines changed: 22 additions & 2 deletions

File tree

  • crates/emmylua_code_analysis/src

crates/emmylua_code_analysis/src/db_index/type/type_decl.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ impl LuaTypeDecl {
238238
#[derive(Debug, Eq, PartialEq, Hash, Clone)]
239239
pub enum LuaTypeIdentifier {
240240
Global(SmolStr),
241-
Local(FileId, SmolStr),
241+
Local(FileId, SmolStr)
242242
}
243243

244244
#[derive(Debug, Eq, PartialEq, Hash, Clone)]

crates/emmylua_code_analysis/src/semantic/generic/tpl_pattern/mod.rs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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+
109129
pub 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

Comments
 (0)