summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/anf.ml2
-rw-r--r--test/c/shadow_let.expect3
-rw-r--r--test/c/shadow_let.sail14
3 files changed, 18 insertions, 1 deletions
diff --git a/src/anf.ml b/src/anf.ml
index d4ad86b8..e87f2bfd 100644
--- a/src/anf.ml
+++ b/src/anf.ml
@@ -196,7 +196,7 @@ let rec aexp_rename from_id to_id (AE_aux (aexp, env, l)) =
| AE_cast (aexp, typ) -> AE_cast (recur aexp, typ)
| AE_assign (id, typ, aexp) when Id.compare from_id id = 0 -> AE_assign (to_id, typ, aexp_rename from_id to_id aexp)
| AE_assign (id, typ, aexp) -> AE_assign (id, typ, aexp_rename from_id to_id aexp)
- | AE_let (mut, id, typ1, aexp1, aexp2, typ2) when Id.compare from_id id = 0 -> AE_let (mut, id, typ1, aexp1, aexp2, typ2)
+ | AE_let (mut, id, typ1, aexp1, aexp2, typ2) when Id.compare from_id id = 0 -> AE_let (mut, id, typ1, recur aexp1, aexp2, typ2)
| AE_let (mut, id, typ1, aexp1, aexp2, typ2) -> AE_let (mut, id, typ1, recur aexp1, recur aexp2, typ2)
| AE_block (aexps, aexp, typ) -> AE_block (List.map recur aexps, recur aexp, typ)
| AE_return (aval, typ) -> AE_return (aval_rename from_id to_id aval, typ)
diff --git a/test/c/shadow_let.expect b/test/c/shadow_let.expect
new file mode 100644
index 00000000..133cecaa
--- /dev/null
+++ b/test/c/shadow_let.expect
@@ -0,0 +1,3 @@
+x = 3
+x = 5
+x = 7
diff --git a/test/c/shadow_let.sail b/test/c/shadow_let.sail
new file mode 100644
index 00000000..18410c74
--- /dev/null
+++ b/test/c/shadow_let.sail
@@ -0,0 +1,14 @@
+default Order dec
+
+$include <prelude.sail>
+
+val main : unit -> unit
+
+function main() = {
+ let x : int = 3;
+ print_int("x = ", x);
+ let x = x + 2;
+ print_int("x = ", x);
+ let x = x + 2;
+ print_int("x = ", x)
+} \ No newline at end of file