fix: incorrect 'unused::constructor'

`ExprTyper` was not incrementing the usage of a constructor
when infering `RecordAccess`.

closes #554
This commit is contained in:
rvcas
2023-10-12 17:43:15 -04:00
parent 52dfc13f8f
commit 55f89a7ff4
2 changed files with 41 additions and 5 deletions

View File

@@ -82,6 +82,37 @@ fn validator_illegal_arity() {
))
}
#[test]
fn mark_constructors_as_used_via_field_access() {
let source_code = r#"
type Datum {
D0(D0Params)
D1(D1Params)
}
type D0Params {
foo: Int,
}
type D1Params {
bar: Int,
}
validator {
fn foo(d: Datum, _r, _c) {
when d is {
D0(params) -> params.foo == 1
D1(_params) -> False
}
}
}
"#;
let (warnings, _) = check_validator(parse(source_code)).unwrap();
assert_eq!(warnings.len(), 1)
}
#[test]
fn validator_correct_form() {
let source_code = r#"