erg-lang / erg

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

Type narrowing with `filter` #497

Closed mtshiba closed 8 months ago

mtshiba commented 8 months ago

Now, this code passes type checking.

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