mirror of
https://github.com/erg-lang/erg.git
synced 2025-08-04 10:49:54 +00:00
fix: type inference bug
This commit is contained in:
parent
0ffa23affd
commit
e48311ee0c
4 changed files with 25 additions and 5 deletions
|
@ -41,3 +41,10 @@ val = val!()
|
|||
|
||||
xs as [Nat or Str; _] = [1, 2, "aa"]
|
||||
ys = list filter x -> x in Int, xs
|
||||
|
||||
ff! x: Str or NoneType =
|
||||
if! x isnot! None:
|
||||
do!: f1! x
|
||||
do!: f0!()
|
||||
f0!() = print! ""
|
||||
f1! _: Str = f0!()
|
||||
|
|
|
@ -93,6 +93,9 @@ fn _test_infer_types() -> Result<(), ()> {
|
|||
module
|
||||
.context
|
||||
.assert_var_type("ys", &unknown_len_list_t(Nat))?;
|
||||
module
|
||||
.context
|
||||
.assert_var_type("ff!", &func1(Str | NoneType, NoneType))?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue