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 + ^