[erlang-questions] Opaque types vs lists:foldl

Magnus Henoch magnus.henoch@REDACTED
Wed Nov 30 13:51:26 CET 2011


Hi all,

I just discovered that when running Dialyzer on this module:

-module(foo).

-export([foo/0]).

-record(x, {y = []}).
-opaque state() :: #x{}.

foo() ->
    lists:foldl(fun bar/2, #x{}, [a, b, c]).

bar(A, X) ->
    X#x{y = [A|X#x.y]}.

I get:

foo.erl:8: Function foo/0 has no local return

If I comment out the "-opaque" line or change it to "-type", the error
goes away.  I get the same result with R14B01 and R15A.

Is this a bug or a feature?

-- 
Magnus Henoch
Erlang Solutions Ltd
http://www.erlang-solutions.com/




More information about the erlang-questions mailing list