From d97e6b84bfb66c141e3dfadb8edbd9afada77664 Mon Sep 17 00:00:00 2001 From: Alasdair Armstrong Date: Thu, 30 Aug 2018 15:33:18 +0100 Subject: 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. --- test/c/stack_struct.expect | 1 + test/c/stack_struct.sail | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 test/c/stack_struct.expect create mode 100644 test/c/stack_struct.sail (limited to 'test/c') 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 -- cgit v1.2.3