-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #571 from erszcz/skip-maybe
Skip functions using maybe expr, don't crash on maybe ... else
- Loading branch information
Showing
5 changed files
with
112 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
test/known_problems/should_fail/maybe_expr_should_fail.erl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
-module(maybe_expr_should_fail). | ||
|
||
-ifdef(OTP_RELEASE). | ||
-if(?OTP_RELEASE >= 25). | ||
-if(?FEATURE_AVAILABLE(maybe_expr)). | ||
|
||
-feature(maybe_expr, enable). | ||
|
||
-export([check1/0, check2/0]). | ||
-export([infer1/0, infer2/1]). | ||
|
||
-spec check1() -> integer(). | ||
check1() -> | ||
maybe | ||
ok ?= ok, | ||
"one" | ||
end. | ||
|
||
-spec check2() -> integer(). | ||
check2() -> | ||
maybe | ||
ok ?= not_ok, | ||
one | ||
else | ||
_ -> "two" | ||
end. | ||
|
||
-spec infer1() -> integer(). | ||
infer1() -> | ||
R = maybe | ||
ok ?= ok | ||
end, | ||
R. | ||
|
||
-spec infer2(string()) -> integer(). | ||
infer2(Val) -> | ||
R = maybe | ||
ok ?= Val | ||
else | ||
_ -> ok | ||
end, | ||
R. | ||
|
||
-endif. %% FEATURE_AVAILABLE | ||
-endif. %% OTP >= 25 | ||
-endif. %% OTP_RELEASE |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
-module(maybe_expr_pass). | ||
|
||
-ifdef(OTP_RELEASE). | ||
-if(?OTP_RELEASE >= 25). | ||
-if(?FEATURE_AVAILABLE(maybe_expr)). | ||
|
||
-feature(maybe_expr, enable). | ||
|
||
-export([check1/0, check2/0]). | ||
-export([infer1/0, infer2/1]). | ||
|
||
-spec check1() -> integer(). | ||
check1() -> | ||
maybe | ||
ok ?= ok, | ||
1 | ||
end. | ||
|
||
-spec check2() -> integer(). | ||
check2() -> | ||
maybe | ||
ok ?= not_ok, | ||
1 | ||
else | ||
_ -> 2 | ||
end. | ||
|
||
-spec infer1() -> integer(). | ||
infer1() -> | ||
R = maybe | ||
ok ?= ok, | ||
1 | ||
end, | ||
R. | ||
|
||
-spec infer2(string()) -> {ok, string()} | error. | ||
infer2(Val) -> | ||
R = maybe | ||
"ok" ?= Val, | ||
{ok, Val} | ||
else | ||
_ -> error | ||
end, | ||
R. | ||
|
||
-endif. %% FEATURE_AVAILABLE | ||
-endif. %% OTP >= 25 | ||
-endif. %% OTP_RELEASE |