summaryrefslogtreecommitdiff
path: root/test/c
diff options
context:
space:
mode:
authorAlasdair2018-08-18 01:23:02 +0100
committerAlasdair2018-08-18 01:25:06 +0100
commit3414ffbc4d62f5cb019def6a6e9931319ac1ffa7 (patch)
tree4b703f42d6ede80a889f4016812aefa3f8353435 /test/c
parent79176c7ac58900c95db5db9cf75978e91e9a453c (diff)
Correctly handle specialising polymorphic types in nested unions
Ensure that this works even when the union types are dependent in the wrong order, before topologically sorting definitions. We do this by calling fix_variant_ctyps on all cdefs by passing a list of prior cdefs to specialize_variants.
Diffstat (limited to 'test/c')
-rw-r--r--test/c/option_nest.expect1
-rw-r--r--test/c/option_nest.sail18
2 files changed, 19 insertions, 0 deletions
diff --git a/test/c/option_nest.expect b/test/c/option_nest.expect
new file mode 100644
index 00000000..9daeafb9
--- /dev/null
+++ b/test/c/option_nest.expect
@@ -0,0 +1 @@
+test
diff --git a/test/c/option_nest.sail b/test/c/option_nest.sail
new file mode 100644
index 00000000..995bf074
--- /dev/null
+++ b/test/c/option_nest.sail
@@ -0,0 +1,18 @@
+
+union test ('a : Type) = {
+ Just : 'a,
+ Nothing : unit
+}
+
+union option ('a : Type) = {
+ None : unit,
+ Some : 'a
+}
+
+val "print_endline" : string -> unit
+
+function main() : unit -> unit = {
+ let _ : test(option(int)) = Just(None());
+ let Just(Some(x)) = Just(Some("test"));
+ print_endline(x)
+} \ No newline at end of file