fix: Discard not taken into account in backpassing

closes #890

Co-authored-by: Kasey White <kwhitemsg@gmail.com>
This commit is contained in:
rvcas
2024-03-20 17:53:17 -04:00
parent 898ef74457
commit 4f8e900aac
3 changed files with 57 additions and 13 deletions

View File

@@ -2008,3 +2008,25 @@ fn correct_span_for_backpassing_args() {
matches!(&warnings[0], Warning::UnusedVariable { ref name, location } if name == "b" && location.start == 245 && location.end == 246)
);
}
#[test]
fn allow_discard_for_backpassing_args() {
let source_code = r#"
fn fold(list: List<a>, acc: b, f: fn(a, b) -> b) -> b {
when list is {
[] -> acc
[x, ..xs] -> fold(xs, f(x, acc), f)
}
}
pub fn sum(list: List<Int>) -> Int {
let a, _b <- fold(list, 0)
a + 1
}
"#;
let (warnings, _ast) = check(parse(source_code)).unwrap();
assert_eq!(warnings.len(), 0);
}