From 63d5a77687521e03ecba6ba7125d0ba2ae8d8a91 Mon Sep 17 00:00:00 2001 From: radrow Date: Fri, 7 Feb 2020 22:52:59 +0100 Subject: [PATCH] Restrict relation operators to ints --- src/aeso_ast_infer_types.erl | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/aeso_ast_infer_types.erl b/src/aeso_ast_infer_types.erl index e5fcc68..85ca227 100644 --- a/src/aeso_ast_infer_types.erl +++ b/src/aeso_ast_infer_types.erl @@ -1469,12 +1469,16 @@ infer_infix({IntOp, As}) Int = {id, As, "int"}, {fun_t, As, [], [Int, Int], Int}; infer_infix({RelOp, As}) - when RelOp == '=='; RelOp == '!='; - RelOp == '<'; RelOp == '>'; - RelOp == '<='; RelOp == '=<'; RelOp == '>=' -> + when RelOp == '=='; RelOp == '!=' -> T = fresh_uvar(As), %% allow any type here, check in ast_to_icode that we have comparison for it Bool = {id, As, "bool"}, {fun_t, As, [], [T, T], Bool}; +infer_infix({RelOp, As}) + when RelOp == '<'; RelOp == '>'; + RelOp == '<='; RelOp == '=<'; RelOp == '>=' -> + Int = {id, As, "int"}, + Bool = {id, As, "bool"}, + {fun_t, As, [], [Int, Int], Bool}; infer_infix({'..', As}) -> Int = {id, As, "int"}, {fun_t, As, [], [Int, Int], {app_t, As, {id, As, "list"}, [Int]}};