Skip to content

Commit 63ac688

Browse files
committed
Resolve generic false positives in the MissingReturn check.
1 parent 189f718 commit 63ac688

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

crates/emmylua_code_analysis/src/diagnostic/checker/check_return_count.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ fn check_missing_return(
8282
if let Some(ty) = variadic.get_type(i) {
8383
if ty.is_optional() {
8484
real_min_len -= 1;
85+
} else if ty.is_tpl() {
86+
real_min_len -= 1;
8587
} else {
8688
break;
8789
}

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -496,4 +496,16 @@ mod tests {
496496
"#,
497497
));
498498
}
499+
500+
#[test]
501+
fn test_pcall_missing_return() {
502+
let mut ws = VirtualWorkspace::new_with_init_std_lib();
503+
504+
assert!(ws.check_code_for(
505+
DiagnosticCode::MissingReturn,
506+
r#"
507+
pcall(function() end)
508+
"#,
509+
));
510+
}
499511
}

0 commit comments

Comments
 (0)