summaryrefslogtreecommitdiff
path: root/test/c
diff options
context:
space:
mode:
authorAlasdair Armstrong2018-08-30 15:33:18 +0100
committerAlasdair Armstrong2018-08-30 15:34:46 +0100
commitd97e6b84bfb66c141e3dfadb8edbd9afada77664 (patch)
treef9086b2bea34d909410946c729e55be731782a31 /test/c
parenta5ad2059821b86ef26a86d78c40cc680c57aa94e (diff)
C: Fix an issue with struct field being generalised inside polymorphic constructors
Add a new printing function for debugging that recursively prints constructor types. Fix an interpreter bug when pattern matching on constructors with tuple types.
Diffstat (limited to 'test/c')
-rw-r--r--test/c/stack_struct.expect1
-rw-r--r--test/c/stack_struct.sail26
2 files changed, 27 insertions, 0 deletions
diff --git a/test/c/stack_struct.expect b/test/c/stack_struct.expect
new file mode 100644
index 00000000..67898e77
--- /dev/null
+++ b/test/c/stack_struct.expect
@@ -0,0 +1 @@
+q = 3
diff --git a/test/c/stack_struct.sail b/test/c/stack_struct.sail
new file mode 100644
index 00000000..c5c79a81
--- /dev/null
+++ b/test/c/stack_struct.sail
@@ -0,0 +1,26 @@
+default Order dec
+
+type bits ('n : Int) = vector('n, dec, bit)
+
+union option ('a : Type) = {
+ Some : 'a,
+ None : unit
+}
+
+struct test = {
+ bits1 : bits(32),
+ bits2 : bits(32)
+}
+
+val "print_int" : (string, int) -> unit
+
+val main : unit -> unit
+
+function main() = {
+ let x : int = 3;
+ let y = Some((x, struct { bits1 = 0xDEADBEEF, bits2 = 0xCAFECAFE } : test));
+ match y {
+ Some(q, w) => print_int("q = ", q),
+ None() => ()
+ }
+} \ No newline at end of file