Skip to content

Dialyzer blames Erlang header instead of LFE code #494

@dendrown

Description

@dendrown

Hello. There seems to be a strange issue when running rebar3 dialyzer on LFE modules that include an Erlang header file. A warning in the LFE code is flagged as occurring in the Erlang header file.

Take, for example, a project with this source file pets.lfe:

(defmodule pets
  (export
   (test 0)))

(include-file "include/dog.lfe")
(include-lib "include/cat.hrl")

(defun test () 
  "Show the problem."
  (flet (;; CALLED IN MAIN BODY
         (doggie () 
           (io:format "DOG: ~p~n" `(,(make-dog))))

         ;; NEVER CALLED!
         (kitty () 
           (io:format "CAT: ~p~n" `(,(make-cat)))))
    (doggie)))

The dog record is defined in include/dog.lfe:

(defrecord dog
  (name 'fido))

The cat record in include/cat.hrl:

-record(cat,
        {name = pickles}).

Running dialyzer detects that we never call (kitty) from the flet, but dialyzer reports the issue in cat.hrl.

$ rebar3 dialyzer
===> Verifying dependencies...
.
.
.
===> Analyzing 1 files with _build/default/rebar3_26.2.1_plt...

src/include/cat.hrl
Line 8: Function '-lfe-test/0-local-kitty/0-1-'/0 will never be called
===> Warnings written to _build/default/26.2.1.dialyzer_warnings
===> Warnings occurred running dialyzer: 1

I put this example together for this issue, but we have seen the problem a number of times in our larger project. I hope it isn't too obscure, and I appreciate your looking
into it when you get a chance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions