Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4589836
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T22:08:51+00:00 2026-05-21T22:08:51+00:00

In a project with about 6000 lines of Erlang code but no type -spec()

  • 0

In a project with about 6000 lines of Erlang code but no type -spec() annotation yet I tried the following:

typer --annotate *.erl

The I replaced all *.erl files with the annotated ones and ran

dialyzer --src -c *.erl

I expected to get lots of warnings (ran the dialyzer/typer combination the first time) but after doing its thing all dialyzer reported were 2 old calls in user_default to meanwhile nonexistent functions.

No other of the default warnings did trigger.

Did I make a mistake using it or is a result like this common?

Is the combination of auto annotation with typer and dialyzer not so useful or am I just lucky and my code doesn’t have issues?


Sidenote: I had to comment out 3 or 4 -spec()s because dialyzer crashed on them.

I’m using Dialyzer v2.2.0 and TypEr version v0.1.7.4 from Erlang R13B04

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T22:08:52+00:00Added an answer on May 21, 2026 at 10:08 pm

    As a side effect of reporting a bug on the erlang-bugs list I got an detailed answer this from Kostis Sagonas, the inventor of dialyzer and typer.

    To my side question I got the following great and detailed answer:

    On Sun, May 1, 2011 at 5:53 PM, Kostis Sagonas wrote:

    Peer Stritzinger wrote:

    BTW: is it normal not to get any warnings when just doing –annotate
    in typer and then dialyzer with no manually tweaked spec’s

    Yes. In fact, typer is just a front end for dialyzer’s basic type inference (i.e. without the warning identification component).

    IMO, there is very little point in doing this if you do not intend to manually “massage” the specs that you get and provide more info for some of them. Take a look at your previous program. The fact that the two <<:64,:_*8>> types were referring to the same quantity could be expressed better if you introduced a type as in:

      -type packet() :: <<_:64,_:_*8>>,
    

    Similarly for channel:

      -type channel() :: atom() | pid() |{atom(),_}.
    

    and then the spec would already look better. Also, dialyzer/typer has no info on what type of fun you intend to use in the second argument of function recv/3 but you do! From the code it is clear that it takes #can_pkt{} record, so why don’t you add appropriate types to its fields and introduce a type for it?

      -record(can_pkt, {id :: id(), data :: binary(), timestamp :: ts()}).
      -type can_pkt() :: #can_pkt{}.
    

    then the specs can look much better:

      -spec recv(packet(), fun((can_pkt()) -> R), channel()) -> R.
      -spec decode(packet()) -> can_pkt().
    

    and note that I’ve used a placeholder type variable R to denote the fact that function recv/2 returns whatever type the fun in its second argument returns. You probably know what this type is so you should also introduce a type for it and use its proper name.

    Hope this helps,

    Kostis

    PS. It’s a pity you posted this in erlang-bugs as the information contained in the above is IMO more interesting than the actual bug.

    Since he refers to a code fragment, I included in my bug report, I include it here. The following code fragment was automatically annotated by typer --annotate:

    -record(can_pkt, {id, data, timestamp}).
    
    -spec recv(<<_:64,_:_*8>>,fun((_) -> 
          any()),atom() | pid() | {atom(),_}) -> any().
    
    recv(Packet, Recv_fun, Chan) ->
        P = decode(Packet),
        #can_pkt{id=Can_id, data=Can_data}=P,
        Recv_fun(P).
    
    -spec decode(<<_:64,_:_*8>>) -> 
          #can_pkt{id::<<_:11>>,data::binary(),timestamp::char()}.
    
    decode(<<_:12, Len:4, Timestamp:16,
            0:3, Id:11/bitstring, 0:18,
            Data:Len/binary, _/binary>>) ->
        #can_pkt{id=Id, data=Data, timestamp=Timestamp}.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have one android project.I have one class file of about 6000 lines when
The project is about translating semi-natural language to SQL tables. The code: label(S) -->
I have been working on a web services related project for about the last
For a new Java web project I thought about using: Eclipse as IDE Mercurial
I'm several layers/levels above the people involved in the project I'm about to describe.
Thinking about getting into .net technology project management I've had plenty of experience with
I'm about to start a project for a customer who wants CMS-like functionality. They
I'm about to start a project that will record and edit audio files, and
I am about to start a new project and would like to document its
I am about to start a project for a potentially heavily accessed ASPNET MVC

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.