<div dir="ltr">Hi list,<div><br></div><div>I noticed that the below code snippet although compiles and works fine results in a dialyzer error (on for example OTP 19.1)</div><div><br></div><div><div>```</div><div>-module(ms).</div><div>-export([t/0]).<br></div><div><br></div><div>-include_lib("stdlib/include/ms_transform.hrl").</div><div><br></div><div>t() -></div><div>    MS = dbg:fun2ms(fun(All) -> message(All) end),</div><div>    erlang:trace_pattern({m, f, '_'}, MS).</div><div>```</div><div><br></div><div>and the error is</div><div><br></div><div>ms.erl:9: The call erlang:trace_pattern({'m', 'f', '_'},MS::[{'$1',[],[{'message','$1'},...]},...]) breaks the contract (MFA,MatchSpec) -> non_neg_integer() when MFA :: trace_pattern_mfa() | 'send' | 'receive', MatchSpec :: MatchSpecList::trace_match_spec() | boolean() | 'restart' | 'pause'</div><div><br></div><div>The reason is that dbg:fun2ms generates the match-spec: [{'$1',[],[{message,'$1'}]}]</div></div><div>But the type as seen in erlang.erl or erts_internal.erl only allows a list or the wildcard atom '_' as the match-spec head.</div><div><div>-type trace_match_spec() :: [{[term()] | '_' ,[term()],[term()]}].</div></div><div><br></div><div>The match-spec grammar definition in <a href="http://erlang.org/doc/apps/erts/match_spec.html">http://erlang.org/doc/apps/erts/match_spec.html</a> clearly allows a match variable as head but I understand it is impossible to express '$<number>' as a proper erlang type.</div><div><br></div><div>I'm not sure if ms_transform should be modified to always generate match-specs according to the type spec or rather the type-spec should be adjusted to allow all legal match specifications (eg by adding atom() to the match head type)</div><div><br></div><div><br></div><div>thanks</div><div>Peter</div> <br><div><br></div><div><br></div></div>