distel:get_arglists("json2", "encode") crash distel every time
leoliu opened this issue · 2 comments
leoliu commented
So I was using distel with yaws and found this bug. Tested on Mac OS X with Erlang R16B03 and yaws 1.98.
(devel@localhost)23> catch distel:src_args(Forms, encode, 1).
{'EXIT',{function_clause,[{distel,src_args,
[[],encode,1],
[{file,"distel.erl"},{line,938}]}]}}
distel:src_args has this comment: %% if we get to [] we have a serious error.
This is due to the pattern match in distel:src_args
doesn't match against func
but function
. An example element of the Forms
argument looks like this:
{tree,function,
{attr,98,[],none},
{func,{tree,atom,{attr,98,[],none},encode_string},
[{tree,clause,
{attr,98,[],none},
{clause,[{var,98,'B'}],
{tree,disjunction,{...},...},
[{tree,...}]}},
{tree,clause,
{attr,99,[],none},
{clause,[{var,99,...}],none,[{...}]}}]}}
massemanet commented
can you post an example of erlang code that triggers this?
leoliu commented
Get json2 from https://raw.github.com/klacke/yaws/master/src/json2.erl and compile without debug_info and load it.
Eval this in the eshell:
catch distel:get_arglists("json2", "encode").