From 6f4ad20b7dadd1bdcf3ec5fc3919cf5fb70d1c1f Mon Sep 17 00:00:00 2001 From: pca006132 Date: Wed, 23 Dec 2020 16:30:23 +0800 Subject: [PATCH] better error msg --- toy-impl/parse_stmt.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/toy-impl/parse_stmt.py b/toy-impl/parse_stmt.py index b987a73..864b21a 100644 --- a/toy-impl/parse_stmt.py +++ b/toy-impl/parse_stmt.py @@ -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: