From 54d18f2d19f33aae822dca53485afa8ba9e06e81 Mon Sep 17 00:00:00 2001 From: Thomas Bauereiss Date: Thu, 25 Jan 2018 11:18:10 +0000 Subject: Fix more type annotations in rewriter Use consistent nesting of tuples when adding updated local mutable variables to expressions. Add test case. --- test/typecheck/pass/if_var_updates.sail | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 test/typecheck/pass/if_var_updates.sail (limited to 'test/typecheck') diff --git a/test/typecheck/pass/if_var_updates.sail b/test/typecheck/pass/if_var_updates.sail new file mode 100644 index 00000000..13d50e88 --- /dev/null +++ b/test/typecheck/pass/if_var_updates.sail @@ -0,0 +1,25 @@ +val add_int = {ocaml: "add", lem: "integerAdd"}: (int, int) -> int + +overload operator + = {add_int} + +val sub_int = {ocaml: "sub", lem: "integerMinus"}: (int, int) -> int + +overload operator - = {sub_int} + +val lt_int = {ocaml: "lt_int", lem: "lt"} : (int, int) -> bool + +overload operator < = {lt_int} + +function foo w : int -> (bool, int) = { + x : int = w; + y : int = 0 - w; + let pos : bool = + if (w < 0) then { + x = 0 - x; + false + } else { + y = 0 - w; + true + }; + (pos, x + y) +} -- cgit v1.2.3