[erlang-questions] Unlike behavior in -spec and type importing

Ivan Carmenates García co7eb@REDACTED
Sun Aug 11 23:02:31 CEST 2013


Hi Chris,

 

I didn’t knew about the function of the dialyzer tool application, I read the documentation and I finally got it to work, It was a little hard because I’m using windows but I finally came with a solution:

 

When I tried to start the dialyzer I got an error of it couldn’t find the PLT file  etc, etc. 

I read about an Environment Variable called DIALYZER_PLT and I gave it the value c:\Program Files\erl5.10.1\usr\PLT\countlink.plt

 

So I built the PLT file using the common applications I use in my project

 

dialyzer --build_plt --output_plt "c:\Program Files\erl5.10.1\usr\PLT\countlink.plt" --apps stdlib kernel

 

 

Them I use another script to update the PLT file with my beams and at the same time get a result.

 

@echo off

mode 100, 40

 

dialyzer --add_to_plt -r "d:\WORK\countlink-1.0\src" --output_plt "c:\Program Files\erl5.10.1\usr\PLT\countlink.plt"

echo.

echo.

echo. 

echo ************************************************************* 

echo *                       Dialyzer Results                    *

echo *************************************************************

dialyzer -r "d:\WORK\countlink-1.0\src"

echo.

pause 

 

I wonder about what for is the PLT file but I think, following my guessing that it content the necessary information of types and functions exporting and many other things.

Because I did test it excluding for example, one my beams with debug information which had an exported type, I use that type in another module included in the PLT and I got an error of undefined type, then I include it again and resulted in no errors.

 

That’s very good the Dialyzer application, but I still think that the compiler should be aware of that minor details, maybe not something like unreachable code detection or unnecessary testing like Dialyser do, still it could also do that, Microsoft CShard Compiler does it, ups sorry about that ;).

 

Well I hope in the future the community fix or adds that little things to the Erlang compiler that is so important (I think one of the most important modules).

 

Cheers,

Ivan.

 

 

 

 

 

 

 

De: Chris King [mailto:colanderman@REDACTED] 
Enviado el: domingo, 11 de agosto de 2013 11:27
Para: erlang-questions@REDACTED; Ivan Carmenates García
Asunto: Re: [erlang-questions] Unlike behavior in -spec and type importing

 

Hi Ivan,

 

On Sun, 11 Aug 2013 11:14:16 -0400, Ivan Carmenates García < <mailto:co7eb@REDACTED> co7eb@REDACTED> wrote:

I check the source of application module to see if the start_type() type was exported and it is not.

And my module compiles well, and even I changed to StartType :: unknown_module: unknown_type() type and it still compiles,

It seems that there are no type checking outside of the module.

 

Are you using Dialyzer to check types?  The Erlang compiler itself does not perform typechecking.  You can run Dialyzer (included with OTP) on your source code like this:

 

$ dialyzer --src <source code directory>

 

or, if you compile your code with debugging enabled, you can run it like this:

 

$ dialyzer <object file directory>

 

In addition to inferring types, Dialyzer will check that code adheres to -spec declarations, and it will warn about unexported types.

 

Note that you have to run Dialyzer on *all* your modules, as it only sees the modules you tell it about, and those whose specifications have been explicitly stored in its "PLT" database (by default erts, kernel, and stdlib).

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20130811/c0d81b17/attachment.htm>


More information about the erlang-questions mailing list