Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The code rejected by Dialyzer5 but not by Fialyzer #274

Open
yuezato opened this issue Jul 18, 2019 · 0 comments
Open

The code rejected by Dialyzer5 but not by Fialyzer #274

yuezato opened this issue Jul 18, 2019 · 0 comments

Comments

@yuezato
Copy link
Collaborator

yuezato commented Jul 18, 2019

The following code is taken from https://learnyousomeerlang.com/dialyzer#typing-functions

-module(cards).
-export([kind/1, main/0]).

-type suit() :: spades | clubs | hearts | diamonds.
-type value() :: 1..10 | j | q | k.
-type card() :: {suit(), value()}.

-spec kind(card()) -> face | number.
kind({_, A}) when A >= 1, A =< 10 -> number;
kind(_) -> face.

main() ->
    number = kind({spades, 7}),
    face   = kind({hearts, k}),
    number = kind({rubies, 4}),
    face   = kind({clubs, q}).

Dialyzer

$ erl --version
Erlang/OTP 22 [erts-10.4.3] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1] [hipe] [dtrace]
$ dialyzer --version
Dialyzer version v4.0.1
$ dialyzer cards.erl
  Checking whether the PLT /Users/yuuya_uezato/.dialyzer_plt is up-to-date... yes
  Proceeding with analysis...
cards.erl:12: Function main/0 has no local return
cards.erl:15: The call cards:kind
         ({'rubies', 4}) breaks the contract
          (card()) -> 'face' | 'number'
 done in 0m0.17s
done (warnings were emitted)

Fialyzer

$ erlc +debug_info cards.erl
$ ../_build/default/bin/main.exe cards.beam
done (passed successfully)
@yuezato yuezato changed the title The code rejected by Dialyzer but not by Fialyzer The code rejected by Dialyzer5 but not by Fialyzer Jul 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant