mirror of
https://github.com/erg-lang/erg.git
synced 2025-09-27 19:59:07 +00:00
fix: union types bug & multi-pattern def bug
This commit is contained in:
parent
7c8b8a66a1
commit
fc85265d9f
14 changed files with 299 additions and 88 deletions
|
@ -10,14 +10,18 @@ def in_operator(elem, y):
|
|||
return True
|
||||
# TODO: trait check
|
||||
return False
|
||||
elif issubclass(type(y), list) and (
|
||||
type(y[0]) == type or issubclass(type(y[0]), Range)
|
||||
elif isinstance(y, list) and (
|
||||
type(y[0]) == type or isinstance(y[0], Range)
|
||||
):
|
||||
# FIXME:
|
||||
type_check = in_operator(elem[0], y[0])
|
||||
len_check = len(elem) == len(y)
|
||||
return type_check and len_check
|
||||
elif issubclass(type(y), dict) and issubclass(type(next(iter(y.keys()))), type):
|
||||
elif isinstance(y, tuple):
|
||||
type_check = all(map(lambda x: in_operator(x[0], x[1]), zip(elem, y)))
|
||||
len_check = len(elem) == len(y)
|
||||
return type_check and len_check
|
||||
elif isinstance(y, dict) and isinstance(next(iter(y.keys())), type):
|
||||
# TODO:
|
||||
type_check = True # in_operator(x[next(iter(x.keys()))], next(iter(y.keys())))
|
||||
len_check = len(elem) >= len(y)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue