[erlang-questions] dialyzer issue with opaque types

Samuel <>
Thu Sep 19 09:35:02 CEST 2013


Hi,

I have next two (trimmed down) modules I want to dialyze (attached as well) :

-module(foo).

-export([foo/0]).

-spec foo() -> bar:id().
foo() -> bar:id_undef().

--------------------------------------------------

-module(bar).

-export([id_undef/0]).

-opaque undef() :: -1.
-opaque id() :: undef().

-export_type([id/0, undef/0]).

-spec id_undef() -> id().
id_undef() -> -1.

-----------------------------------------------

Running dialyzer on those fails like this:

$ erlc +debug_info *.erl && dialyzer *.beam
  Checking whether the PLT
/home/samuel/local/var/dialyzer/plts/R16B02-src/otp.plt is
up-to-date...
 yes
  Proceeding with analysis...
foo.erl:5: Invalid type specification for function foo:foo/0. The
success typing is () -> bar:id()
 done in 0m3.02s
done (warnings were emitted)

That is, dialyzer thinks that bar:id() is the bad result type and that
I should be using bar:id() instead :)

Making undef() not opaque seems to solve the issue.

I have verified this in both R15B03 and R16B02

-- 
Samuel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: foo.erl
Type: application/octet-stream
Size: 84 bytes
Desc: not available
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20130919/8a3802d8/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bar.erl
Type: application/octet-stream
Size: 164 bytes
Desc: not available
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20130919/8a3802d8/attachment-0001.obj>


More information about the erlang-questions mailing list