'exprec' fails to process empty records
I know the example bellow doesn't make much sense, but anyway:
-module(test).
-record(test, {}).
-compile({parse_transform, exprecs}).
-export_records([test]).
... results in the following error with the latest version of parse_trans and Erlang R15B:
src/test.erl:none: internal error in lint_module;
crash reason: {function_clause,
[{erl_lint,'-compiler_options/1-lc$^0/1-0-',
[{error,
[{"src/test.erl",
[{9999,parse_trans,
{function_clause,
[{exprecs,funspec,
[5,'#pos-',[]],
[{file,"src/exprecs.erl"},{line,735}]},
{exprecs,f_pos_2,2,
[{file,"src/exprecs.erl"},{line,991}]},
{exprecs,generate_accessors,2,
[{file,"src/exprecs.erl"},{line,608}]},
{exprecs,generate_specs_and_accessors,2,
[{file,"src/exprecs.erl"},{line,513}]},
{exprecs,verify_generated,3,
[{file,"src/exprecs.erl"},{line,526}]},
{exprecs,do_transform,2,
[{file,"src/exprecs.erl"},{line,425}]},
{parse_trans,top,3,
[{file,"src/parse_trans.erl"},{line,336}]},
{compile,'-foldl_transform/2-anonymous-2-',2,
[{file,"compile.erl"},{line,841}]}]}}]}]}],
[{file,"erl_lint.erl"},{line,474}]},
{erl_lint,compiler_options,1,
[{file,"erl_lint.erl"},{line,474}]},
{erl_lint,module,3,[{file,"erl_lint.erl"},{line,469}]},
{compile,lint_module,1,[{file,"compile.erl"},{line,906}]},
{compile,'-internal_comp/4-anonymous-1-',2,
[{file,"compile.erl"},{line,269}]},
{compile,fold_comp,3,[{file,"compile.erl"},{line,287}]},
{compile,internal_comp,4,[{file,"compile.erl"},{line,271}]},
{compile,internal,3,[{file,"compile.erl"},{line,246}]}]}
Hmm, :)
Thanks. I'll take a look at this a bit later on.
BR, Ulf
Den 11 mars 2012 12:27 skrev Sergei Lebedev < [email protected]
:
I know the example bellow doesn't make much sense, but anyway:
-module(test). -record(test, {}). -compile({parse_transform, exprecs}). -export_records([test]).... results in the following error with the latest version of
parse_transand Erlang R15B:src/test.erl:none: internal error in lint_module; crash reason: {function_clause, [{erl_lint,'-compiler_options/1-lc$^0/1-0-', [{error, [{"src/test.erl", [{9999,parse_trans, {function_clause, [{exprecs,funspec, [5,'#pos-',[]], [{file,"src/exprecs.erl"},{line,735}]}, {exprecs,f_pos_2,2, [{file,"src/exprecs.erl"},{line,991}]}, {exprecs,generate_accessors,2, [{file,"src/exprecs.erl"},{line,608}]}, {exprecs,generate_specs_and_accessors,2, [{file,"src/exprecs.erl"},{line,513}]}, {exprecs,verify_generated,3, [{file,"src/exprecs.erl"},{line,526}]}, {exprecs,do_transform,2, [{file,"src/exprecs.erl"},{line,425}]}, {parse_trans,top,3, [{file,"src/parse_trans.erl"},{line,336}]}, {compile,'-foldl_transform/2-anonymous-2-',2, [{file,"compile.erl"},{line,841}]}]}}]}]}], [{file,"erl_lint.erl"},{line,474}]}, {erl_lint,compiler_options,1, [{file,"erl_lint.erl"},{line,474}]}, {erl_lint,module,3,[{file,"erl_lint.erl"},{line,469}]}, {compile,lint_module,1,[{file,"compile.erl"},{line,906}]}, {compile,'-internal_comp/4-anonymous-1-',2, [{file,"compile.erl"},{line,269}]}, {compile,fold_comp,3,[{file,"compile.erl"},{line,287}]}, {compile,internal_comp,4,[{file,"compile.erl"},{line,271}]}, {compile,internal,3,[{file,"compile.erl"},{line,246}]}]}
Reply to this email directly or view it on GitHub: https://github.com/uwiger/parse_trans/issues/2
And what was wrong?
I haven't fixed it yet. The problem is that the function '#pos-'(Rec, Attr) will never return for an empty record. The code that generates a type signature for all possible return values was not prepared for that.
I'd the same problem with parse_transform (https://github.com/w495/erlang_decorators), but I've solved it with
erl_parse:abstract(Some, Line).