Skip to content

Commit 73ba2ea

Browse files
committed
Fix generic dots params type check
1 parent a5a18d0 commit 73ba2ea

File tree

5 files changed

+30
-2
lines changed

5 files changed

+30
-2
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
# 0.6.0 (unreleased)
44

5+
# 0.5.4
6+
7+
`Fix` Fix generic dots params type check
58

69
# 0.5.3
710

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ members = [
88
[workspace.dependencies]
99
# local
1010
emmylua_code_analysis = { path = "crates/emmylua_code_analysis", version = "0.5.0" }
11-
emmylua_parser = { path = "crates/emmylua_parser", version = "0.10.0" }
11+
emmylua_parser = { path = "crates/emmylua_parser", version = "0.10.1" }
1212
emmylua_diagnostic_macro = { path = "crates/emmylua_diagnostic_macro", version = "0.4.0" }
1313

1414
# external

crates/emmylua_code_analysis/src/diagnostic/test/param_type_check_test.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,4 +284,16 @@ mod test {
284284
"#
285285
));
286286
}
287+
288+
#[test]
289+
fn test_generic_dots_param() {
290+
let mut ws = VirtualWorkspace::new_with_init_std_lib();
291+
292+
assert!(ws.check_code_for(
293+
DiagnosticCode::ParamTypeNotMatch,
294+
r#"
295+
local d = select(1, 1, 2, 3)
296+
"#
297+
));
298+
}
287299
}

crates/emmylua_code_analysis/src/semantic/instantiate/instantiate_class_generic.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,12 @@ pub fn instantiate_doc_function(
111111
new_params.push(param.clone());
112112
}
113113
}
114-
_ => {}
114+
_ => {
115+
new_params.push((
116+
"...".to_string(),
117+
Some(LuaType::Variadic(LuaType::Any.into())),
118+
));
119+
}
115120
}
116121
}
117122
}

crates/emmylua_code_analysis/src/semantic/type_check/simple_type.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ pub fn check_simple_type_compact(
1111
check_guard: TypeCheckGuard,
1212
) -> TypeCheckResult {
1313
match source {
14+
LuaType::Unknown | LuaType::Any => return Ok(()),
1415
LuaType::Nil => {
1516
if let LuaType::Nil = compact_type {
1617
return Ok(());
@@ -156,6 +157,13 @@ pub fn check_simple_type_compact(
156157
compact_type,
157158
check_guard.next_level()?,
158159
);
160+
} else {
161+
return check_simple_type_compact(
162+
db,
163+
source_type,
164+
compact_type,
165+
check_guard.next_level()?,
166+
);
159167
}
160168
}
161169
_ => {}

0 commit comments

Comments
 (0)