Last active
August 29, 2015 13:57
-
-
Save ferd/9767020 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| %% Possible Dialyzer bug | |
| -module(mod). | |
| -export([run/1]). | |
| test(Fun, Arg1, Arg2, Arg3) -> | |
| FinalFun = case check(Arg1) of | |
| reuse -> Fun; | |
| new -> fun do_nothing/2 | |
| end, | |
| case FinalFun(Arg2,Arg3) of | |
| {ok, _Term} -> ok; | |
| {error, Reason} -> {failed, Reason} | |
| end. | |
| do_nothing(_Arg1, _Arg2) -> {ok, done}. | |
| do_something(true, true) -> {ok, true}; | |
| do_something(_, _) -> {error, false}. | |
| check(X) -> | |
| case X rem 2 of | |
| 0 -> reuse; | |
| _ -> new | |
| end. | |
| run(X) -> | |
| test(fun do_something/2, X, b, c). |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Dialyzer run:
Erl runs:
Both cases can visibly work, Dialyzer just loses track of what one of the functions may do. Changing the first case expression to
FinalFun = Funmakes the warning go away.