Restrict relation operators to ints

This commit is contained in:
radrow 2020-02-07 22:52:59 +01:00
parent efd45df820
commit 63d5a77687

View File

@ -1469,12 +1469,16 @@ infer_infix({IntOp, As})
Int = {id, As, "int"}, Int = {id, As, "int"},
{fun_t, As, [], [Int, Int], Int}; {fun_t, As, [], [Int, Int], Int};
infer_infix({RelOp, As}) infer_infix({RelOp, As})
when RelOp == '=='; RelOp == '!='; when RelOp == '=='; RelOp == '!=' ->
RelOp == '<'; RelOp == '>';
RelOp == '<='; RelOp == '=<'; RelOp == '>=' ->
T = fresh_uvar(As), %% allow any type here, check in ast_to_icode that we have comparison for it T = fresh_uvar(As), %% allow any type here, check in ast_to_icode that we have comparison for it
Bool = {id, As, "bool"}, Bool = {id, As, "bool"},
{fun_t, As, [], [T, T], 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}) -> infer_infix({'..', As}) ->
Int = {id, As, "int"}, Int = {id, As, "int"},
{fun_t, As, [], [Int, Int], {app_t, As, {id, As, "list"}, [Int]}}; {fun_t, As, [], [Int, Int], {app_t, As, {id, As, "list"}, [Int]}};