From 6c66433e8db697337032660ac5c1c9869104c6c3 Mon Sep 17 00:00:00 2001 From: Legotier Date: Fri, 10 Jun 2022 14:54:33 +0200 Subject: [PATCH 1/2] Fix typechecker error for expressions that contain / --- probably/pgcl/check.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/probably/pgcl/check.py b/probably/pgcl/check.py index 43169cf..8232a89 100644 --- a/probably/pgcl/check.py +++ b/probably/pgcl/check.py @@ -158,7 +158,7 @@ def get_type(program: Program, if check and expr.operator in [ Binop.LEQ, Binop.LT, Binop.GEQ, Binop.GT, Binop.EQ, Binop.PLUS, - Binop.MINUS, Binop.TIMES, Binop.MODULO, Binop.POWER + Binop.MINUS, Binop.TIMES, Binop.MODULO, Binop.POWER, Binop.DIVIDE ]: rhs_typ = get_type(program, expr.rhs, check=check) if isinstance(rhs_typ, CheckFail): @@ -177,7 +177,7 @@ def get_type(program: Program, # binops that take numeric operands and return a numeric value if expr.operator in [ - Binop.PLUS, Binop.MINUS, Binop.TIMES, Binop.MODULO, Binop.POWER + Binop.PLUS, Binop.MINUS, Binop.TIMES, Binop.MODULO, Binop.POWER, Binop.DIVIDE ]: # intentionally lose the bounds on NatType (see NatType documentation) if isinstance(lhs_typ, NatType) and lhs_typ.bounds is not None: @@ -209,6 +209,7 @@ def get_type(program: Program, return CheckFail.expected_type_got(expr.expr, NatType(None), typ) return typ + print(expr) raise Exception("unreachable") From 130db4ff8ed1066f62f9f24095aa2fb3aaec6803 Mon Sep 17 00:00:00 2001 From: Legotier Date: Fri, 10 Jun 2022 14:55:42 +0200 Subject: [PATCH 2/2] Remove print statement --- probably/pgcl/check.py | 1 - 1 file changed, 1 deletion(-) diff --git a/probably/pgcl/check.py b/probably/pgcl/check.py index 8232a89..ece3e1e 100644 --- a/probably/pgcl/check.py +++ b/probably/pgcl/check.py @@ -209,7 +209,6 @@ def get_type(program: Program, return CheckFail.expected_type_got(expr.expr, NatType(None), typ) return typ - print(expr) raise Exception("unreachable")