mirror of
https://github.com/erg-lang/erg.git
synced 2025-08-03 18:29:00 +00:00
feat: type narrowing with filter
This commit is contained in:
parent
5345b07791
commit
bd39393746
9 changed files with 209 additions and 36 deletions
|
@ -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
|
||||
|
|
|
@ -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(())
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue