From 3e2cd8de57d4bc865f6b8299dd4e5689b5e8b875 Mon Sep 17 00:00:00 2001 From: Alasdair Armstrong Date: Fri, 1 Mar 2019 16:38:03 +0000 Subject: Add a test case for previous commit Also make unifying int against int('n) work as expected for constructor applications. --- test/typecheck/pass/existential_ast2.sail | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 test/typecheck/pass/existential_ast2.sail (limited to 'test') diff --git a/test/typecheck/pass/existential_ast2.sail b/test/typecheck/pass/existential_ast2.sail new file mode 100644 index 00000000..f15d1f57 --- /dev/null +++ b/test/typecheck/pass/existential_ast2.sail @@ -0,0 +1,28 @@ +default Order dec + +$include + +type datasize('n: Int) -> Bool = 'n in {32, 64} + +type regno = range(0, 31) + +union ast = { + Ctor1 : {'d, datasize('d). (nat, int('d), bits(4))}, + Ctor2 : {'d, datasize('d). (int, int('d), bits(4))}, +} + +val decode : bits(16) -> option(ast) + +function clause decode(a : bits(4) @ b : bits(1) @ c : bits(4) @ 0b0000110) = { + let x : {|32, 64|} = if b == 0b0 then 32 else 64; + let a = unsigned(a); + + Some(Ctor1(a, x, c)) +} + +function clause decode(a : bits(4) @ b : bits(1) @ c : bits(4) @ 0b0000111) = { + let x : {|32, 64|} = if b == 0b0 then 32 else 64; + let a = unsigned(a); + + Some(Ctor2(a, x, c)) +} -- cgit v1.2.3