summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/monomorphise.ml6
-rw-r--r--test/mono/mutrecmono.sail33
-rw-r--r--test/mono/pass/mutrecmono1
3 files changed, 40 insertions, 0 deletions
diff --git a/src/monomorphise.ml b/src/monomorphise.ml
index a3de87b7..8ec07f7f 100644
--- a/src/monomorphise.ml
+++ b/src/monomorphise.ml
@@ -48,6 +48,12 @@
(* SUCH DAMAGE. *)
(**************************************************************************)
+(* Could fix list:
+ - Can probably trigger non-termination in the analysis or constant
+ propagation with carefully constructed recursive (or mutually
+ recursive) functions
+*)
+
open Parse_ast
open Ast
open Ast_util
diff --git a/test/mono/mutrecmono.sail b/test/mono/mutrecmono.sail
new file mode 100644
index 00000000..c5ed1c0d
--- /dev/null
+++ b/test/mono/mutrecmono.sail
@@ -0,0 +1,33 @@
+$include <smt.sail>
+$include <flow.sail>
+default Order dec
+type bits ('n : Int) = vector('n, dec, bit)
+val eq_vec = {ocaml: "eq_list", lem: "eq_vec"} : forall 'n. (bits('n), bits('n)) -> bool
+overload operator == = {eq_int, eq_vec}
+val "extz_vec" : forall 'n 'm. (atom('m),vector('n, dec, bit)) -> vector('m, dec, bit) effect pure
+val extz : forall 'n 'm. vector('n, dec, bit) -> vector('m, dec, bit) effect pure
+function extz(v) = extz_vec(sizeof('m),v)
+val UInt = {
+ ocaml: "uint",
+ lem: "uint",
+ interpreter: "uint",
+ c: "sail_uint"
+} : forall 'n. bits('n) -> range(0, 2 ^ 'n - 1)
+
+
+val a : {|8,16,32|} -> int
+val b : {|8,16,32|} -> int
+
+function a 'n = if n == 8 then b(n) else let x : bits('n) = extz(0x12) in UInt(x)
+function b 'n = if n == 32 then a(n) else let x : bits('n) = extz(0x34) in UInt(x)
+
+val run : unit -> unit effect {escape}
+
+function run () = {
+ assert(a(8) == 52);
+ assert(a(16) == 18);
+ assert(a(32) == 18);
+ assert(b(8) == 52);
+ assert(b(16) == 52);
+ assert(a(32) == 18);
+} \ No newline at end of file
diff --git a/test/mono/pass/mutrecmono b/test/mono/pass/mutrecmono
new file mode 100644
index 00000000..1ad1508d
--- /dev/null
+++ b/test/mono/pass/mutrecmono
@@ -0,0 +1 @@
+mutrecmono.sail -auto_mono