better error msg

pull/14/head
pca006132 2020-12-23 16:30:23 +08:00 committed by pca006132
parent 368690ccd9
commit 6f4ad20b7d
1 changed files with 2 additions and 2 deletions

View File

@ -128,12 +128,12 @@ def parse_if_stmt(ctx: Context,
t = parse_expr(ctx, sym_table, node.test.left.args[0])
if not isinstance(t, TypeVariable) or len(t.constraints) < 2:
raise CustomError(
'type guard only support basic type variables with constraints',
'type guard only support basic bounded type variables',
node.test)
t1, _ = parse_type(ctx, node.test.comparators[0])
if t1 not in t.constraints:
raise CustomError(
f'{t1} is not in constraints of {t}',
f'{t1} is not a possible instance of {t}',
node.test)
t2 = [v for v in t.constraints if v != t1]
try: