better error msg
This commit is contained in:
parent
368690ccd9
commit
6f4ad20b7d
@ -128,12 +128,12 @@ def parse_if_stmt(ctx: Context,
|
|||||||
t = parse_expr(ctx, sym_table, node.test.left.args[0])
|
t = parse_expr(ctx, sym_table, node.test.left.args[0])
|
||||||
if not isinstance(t, TypeVariable) or len(t.constraints) < 2:
|
if not isinstance(t, TypeVariable) or len(t.constraints) < 2:
|
||||||
raise CustomError(
|
raise CustomError(
|
||||||
'type guard only support basic type variables with constraints',
|
'type guard only support basic bounded type variables',
|
||||||
node.test)
|
node.test)
|
||||||
t1, _ = parse_type(ctx, node.test.comparators[0])
|
t1, _ = parse_type(ctx, node.test.comparators[0])
|
||||||
if t1 not in t.constraints:
|
if t1 not in t.constraints:
|
||||||
raise CustomError(
|
raise CustomError(
|
||||||
f'{t1} is not in constraints of {t}',
|
f'{t1} is not a possible instance of {t}',
|
||||||
node.test)
|
node.test)
|
||||||
t2 = [v for v in t.constraints if v != t1]
|
t2 = [v for v in t.constraints if v != t1]
|
||||||
try:
|
try:
|
||||||
|
Loading…
Reference in New Issue
Block a user