From 09a85596d8a6792fb057416fe6957a292ca309f4 Mon Sep 17 00:00:00 2001 From: John Doty Date: Wed, 7 Feb 2024 10:09:36 -0800 Subject: [PATCH] [fine] Just some more tests --- fine/tests/expression/alternates.fine | 14 ++++++++++++++ fine/tests/expression/if_mismatched_arms.fine | 3 +++ 2 files changed, 17 insertions(+) create mode 100644 fine/tests/expression/if_mismatched_arms.fine diff --git a/fine/tests/expression/alternates.fine b/fine/tests/expression/alternates.fine index 963f1a8e..d2567276 100644 --- a/fine/tests/expression/alternates.fine +++ b/fine/tests/expression/alternates.fine @@ -14,6 +14,20 @@ fun extract_value(v: Foo or Bar) -> f64 { } // No error; exhaustivity analysis should work. } +// Some type compatibility nonsense +fun bottom() -> string or nothing { + "woooo" +} + +fun same_but_wrong_way_around_should_be_compatible() -> nothing or string { + bottom() +} + +fun same_but_larger_should_be_compatible() -> nothing or f64 or string { + bottom() +} + + // This is Bob Nystrom's example from // https://journal.stuffwithstuff.com/2023/08/04/representing-heterogeneous-data/ // diff --git a/fine/tests/expression/if_mismatched_arms.fine b/fine/tests/expression/if_mismatched_arms.fine new file mode 100644 index 00000000..0f9531a6 --- /dev/null +++ b/fine/tests/expression/if_mismatched_arms.fine @@ -0,0 +1,3 @@ +if true { "blarg" } else { 23 } + +// @type: 0 f64 or string