From d3ee72306e54e2dc0a48c93ba12d9d67f21a479e Mon Sep 17 00:00:00 2001 From: koniifer Date: Tue, 5 Nov 2024 18:07:04 +0000 Subject: [PATCH] optional from eca test --- lang/README.md | 12 ++++++++++++ lang/src/son.rs | 1 + lang/tests/son_tests_optional_from_eca.txt | 3 +++ 3 files changed, 16 insertions(+) create mode 100644 lang/tests/son_tests_optional_from_eca.txt diff --git a/lang/README.md b/lang/README.md index 4dea2e7..509e3e1 100644 --- a/lang/README.md +++ b/lang/README.md @@ -614,6 +614,18 @@ main := fn(): uint { } ``` +#### optional_from_eca +```hb +main := fn(): uint { + a := @as(?uint, @eca(0, 0, 0, 0)) + + if a == null { + die + } + return a +} +``` + #### inlining_issues ```hb main := fn(): void { diff --git a/lang/src/son.rs b/lang/src/son.rs index 46ade6a..be6df45 100644 --- a/lang/src/son.rs +++ b/lang/src/son.rs @@ -4594,5 +4594,6 @@ mod tests { global_aliasing_overptimization; overwrite_aliasing_overoptimization; more_if_opts; + optional_from_eca; } } diff --git a/lang/tests/son_tests_optional_from_eca.txt b/lang/tests/son_tests_optional_from_eca.txt new file mode 100644 index 0000000..82d4c68 --- /dev/null +++ b/lang/tests/son_tests_optional_from_eca.txt @@ -0,0 +1,3 @@ +test.hb:8:2: can't prove the value is not 'null', use '@unwrap()' if you believe compiler is stupid, or explicitly check for null and handle it ('if == null { /* handle */ } else { /* use opt */ }') + return a + ^