feat: type narrowing with filter

This commit is contained in:
Shunsuke Shibayama 2024-03-21 01:29:27 +09:00
parent 5345b07791
commit bd39393746
9 changed files with 209 additions and 36 deletions

View file

@ -38,3 +38,6 @@ val!() =
val!::return x
"d"
val = val!()
xs as [Nat or Str; _] = [1, 2, "aa"]
ys = array filter x -> x in Int, xs

View file

@ -90,6 +90,9 @@ fn _test_infer_types() -> Result<(), ()> {
module
.context
.assert_var_type("val", &v_enum(set! { "b".into(), "d".into() }))?;
module
.context
.assert_var_type("ys", &unknown_len_array_t(Nat))?;
Ok(())
}