Uploaded image for project: 'Erlang/OTP'
  1. Erlang/OTP
  2. ERL-1436

[Dialyzer] Assumed evaluation order + throw = spurious warning

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Not a Bug
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: dialyzer
    • Labels:
      None

      Description

       

      The following `toto.erl` module fails Dialyzer (or vice-versa ):

      -module(toto).
      -export[caller/1].
      caller(X) -> {callee1(X), callee2(X)}.
      callee1(ok) -> ok;
      callee1(ko) -> throw(ko);
      callee1(_)  -> throw(undefined).
      callee2(ok) -> 42;
      callee2(ko) -> throw(ko);
      callee2(_)  -> throw(undefined).
      

      With output:

      src/toto.erl
       12: The pattern 'ko' can never match the type 'ok'
       13: The variable _ can never match since previous clauses completely covered the type 'ok'.
      
      

      That's pretty smart: if we pass callee1(X), that means the only possible value is indeed 'ok'.

      But in Erlang, the order or evaluation is unspecified. That means `callee2` could be called first.

      Expected result:

      • No warning
      • Better: ability to disable this particular warning.

      By the way, it would be very nice if Dialyzer could give more context about how it inferred its type (and inform about the assumed evaluation order).

       

       

       

        Attachments

          Activity

            People

            Assignee:
            hasse Hans Bolinder
            Reporter:
            slaykachu Yves Gerey
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: