erg-lang / erg

A statically typed language compatible with Python
http://erg-lang.org
Apache License 2.0
2.61k stars 53 forks source link

Type narrowing with `filter` #497

Closed mtshiba closed 3 months ago

mtshiba commented 3 months ago

Now, this code passes type checking.

xs: [Nat or NoneType; _] = [1, None, 2]
ys: [Nat; _] = array filter x -> x != None, xs