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])
|
||||
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:
|
||||
|
Loading…
Reference in New Issue
Block a user