[erlang-questions] dialyzer and #record vs tuple

Klas Johansson klas.johansson@REDACTED
Sun Sep 15 23:42:24 CEST 2013


Hi,

I've seen a similar situation.  There was a module with the same name as a
record. The record had two fields.

    module: x.erl
    record: -record(x, {name, opts}).

This module happened to be a process which was started as a supervisor
child with a "StartFunc" like this:

    X = #x{name=Name, opts=Opts},
    ...
    StartFunc = {x, start_link, [X]},
    ...

The StartFunc was (of course) also mistaken for the record, since they look
the same on the tuple level.

/Klas



On Fri, Jun 7, 2013 at 11:23 AM, Vincent de Phily <
vincent.dephily@REDACTED> wrote:

> On Friday 07 June 2013 12:08:18 Kostis Sagonas wrote:
> > There is no perfect `solution' to this .
> >
> > Dialyzer works at a level where records have been expanded into tuples
> > and thus records and tuples are indistinguishable between them.
> > Furthermore, it makes the assumption that within a module any tuple with
> > a record tag and with a size that matches some typed record declaration
> > refers to the declared types. So you have two options:
> >
> >   1. Use different tags for records and tuples e.g. foo_rec vs. foo (as
> > you write)
> >
> >   2. Do not declare types for records that for some reason or another
> > you also want to have similar looking tuples (as you write, declaring
> > the "union" of the types does not make much sense).
> >
> >  From the two options, I personally very much prefer the first.
>
> Thanks for confirming this, pity there's no nice way of handling that
> problem
> but I'll stick with option 1 for now.
>
> Maybe when frames arrive in erlang it'll fix that issue :)
>
> --
> Vincent de Phily
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20130915/d8b87511/attachment.htm>


More information about the erlang-questions mailing list