added check for same variable

This commit is contained in:
pca006132 2020-12-17 17:21:51 +08:00 committed by pca006132
parent 57c7104bf3
commit fe6d9cc446
2 changed files with 3 additions and 0 deletions

View File

@ -32,6 +32,8 @@ def find_subst(ctx: dict[str, Type],
else:
if a not in b.constraints:
return f"{b} cannot take value of {a}"
if a == b:
return sub
if b in a.get_vars():
return "Recursive type is not supported"
sub[b.name] = a

View File

@ -53,6 +53,7 @@ try_case(ListType(i32), ListType(i32), {})
try_case(TupleType([X, X]), TupleType([X, Y]), {})
try_case(TupleType([X, X]), TupleType([Y, Y]), {})
try_case(TupleType([X, Y]), TupleType([X, X]), {})
try_case(TupleType([X, X]), TupleType([X, X]), {})
try_case(TupleType([X, Y]), X, {})
try_case(TupleType([i32, Y]), X, {})