mirror of
https://github.com/erg-lang/erg.git
synced 2025-10-03 05:54:33 +00:00
fix: array type bug
This commit is contained in:
parent
b5f5876631
commit
cf726fe4a8
4 changed files with 19 additions and 2 deletions
|
@ -413,7 +413,14 @@ impl<A: ASTBuildable> GenericASTLowerer<A> {
|
||||||
{
|
{
|
||||||
return Err(self.elem_err(&l, &r, elem));
|
return Err(self.elem_err(&l, &r, elem));
|
||||||
} // else(OK): e.g. [1, "a": Str or Int]
|
} // else(OK): e.g. [1, "a": Str or Int]
|
||||||
} else {
|
}
|
||||||
|
// OK: ?T(:> {"a"}) or ?U(:> {"b"}) or {"c", "d"} => {"a", "b", "c", "d"} <: Str
|
||||||
|
else if self
|
||||||
|
.module
|
||||||
|
.context
|
||||||
|
.coerce(union_.clone(), &())
|
||||||
|
.map_or(true, |coerced| coerced.union_pair().is_some())
|
||||||
|
{
|
||||||
return Err(self.elem_err(&l, &r, elem));
|
return Err(self.elem_err(&l, &r, elem));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,3 +5,8 @@ print! arr[2][0] # ERR
|
||||||
dict = {"a": {"a": 1}, "b": {"b": 2}}
|
dict = {"a": {"a": 1}, "b": {"b": 2}}
|
||||||
print! dict["c"]["a"] # ERR
|
print! dict["c"]["a"] # ERR
|
||||||
print! dict["a"]["c"] # ERR
|
print! dict["a"]["c"] # ERR
|
||||||
|
|
||||||
|
ab = if True:
|
||||||
|
do "a"
|
||||||
|
do "b"
|
||||||
|
_ = [1, 2, ab] # NG
|
||||||
|
|
|
@ -5,3 +5,8 @@ print! x
|
||||||
dic = {"a": {"a": 1}, "b": {"b": 2}}
|
dic = {"a": {"a": 1}, "b": {"b": 2}}
|
||||||
y = dic["a"]["a"]
|
y = dic["a"]["a"]
|
||||||
print! y
|
print! y
|
||||||
|
|
||||||
|
ab = if True: # x: {"a"} or {"b"}
|
||||||
|
do "a"
|
||||||
|
do "b"
|
||||||
|
_ = ["c", "d", ab] # OK
|
||||||
|
|
|
@ -482,7 +482,7 @@ fn exec_class_attr_err() -> Result<(), ()> {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn exec_collection_err() -> Result<(), ()> {
|
fn exec_collection_err() -> Result<(), ()> {
|
||||||
expect_failure("tests/should_err/collection.er", 0, 4)
|
expect_failure("tests/should_err/collection.er", 0, 5)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue