[erlang-questions] internal error in lint_module
Sina Samavati
sina.samv@REDACTED
Sun Jan 19 16:12:18 CET 2014
It is not a bug.
"AST" in parse_transform/2 is a list of abstract forms but the output
of erl_syntax_lib:mapfold/3 is a syntax tree (namely, that "T1"),
that's why it throws some errors because parse_transform/2 should
return a list of abstract forms.
You can give a *list* of syntax trees to erl_syntax:revert_forms/1 to
get a *list* of abstract forms.
On Fri, Jan 17, 2014 at 3:26 PM, Xiao Jia <me@REDACTED> wrote:
> (I posted this to erlang-bugs as well, but it may deserve some
> discussions here.)
>
> I was writing a parse_transform module using erl_syntax_lib:mapfold,
> but both R16B03 and R15B03-1 give the following error even if the
> parse_transform module does nothing:
>
>
> z.erl:none: internal error in lint_module;
> crash reason: {badarg,[{erl_scan,set_attr,
> [line,function,#Fun<erl_lint.9.103090672>],
> [{file,"erl_scan.erl"},{line,418}]},
> ...
> (see https://gist.github.com/stfairy/8471800 for full error)
>
>
> File z.erl:
>
>
> -module(z).
> -compile({parse_transform, zt}).
> -export([f/1]).
> f(_) -> z.
>
>
> File zt.erl:
>
>
> -module(zt).
> -export([parse_transform/2]).
>
> parse_transform(AST, _Options) ->
> [parse(T) || T <- AST].
>
> parse({function, _, _, _, _} = T) ->
> case erl_syntax_lib:mapfold(fun foobar/2, something, T) of
> {T1, _} -> T1;
> _ -> T
> end;
> parse(T) -> T.
>
> foobar(T, S) -> {T, S}.
>
>
> $ erlc zt.erl
> $ erlc -pa . z.erl
>
>
>
> btw, I am a little confused why parse_transform modules are usually
> named as "zt"...
>
>
> --
> Regards,
> Xiao Jia
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
--
Sina Samavati
Software engineer
https://github.com/s1n4
https://twitter.com/sinasamavati
More information about the erlang-questions
mailing list