[erlang-questions] Error in erl_tidy (syntax tools) any fix?

Erik Stenman Erik.Stenman@REDACTED
Wed Aug 22 08:54:59 CEST 2007


Sorry for writing in Swedish to erlang-question,
I didn't really mean to send it to the list.

I wrote that I had received a patch from Richard which might
solve the problem. But on second thought I think the patch
only solves the problem when the type is given as binary,
as in:
  <<(foo(X))/binary>>

So I guess Richard needs to take a deeper look at the whole
handling of expressions inside binaries in syntax_tools.

/Erik Stenman

Erik Stenman wrote:
> Jag fick den bifogade patchen av Richard.
> Den löser nog problemet, och kommer med i nästa version av erl_tidy.
> 
> /Erik Stenman
> 
> Thomas Arts wrote:
>> Erlang R11B, erl 5.5.4 under Windows Vista
>> syntax-tools-1.5.3
>>
>> Save the following program:
>> %%---------------------------------------------------------
>> -module(test7705).
>>
>> -export([header/0]).
>>
>> header() ->
>>     Bin = <<"test7705">>, <<(size(Bin)), Bin/binary>>.
>>
>> %%---------------------------------------------------------
>>
>> Erlang (BEAM) emulator version 5.5.4 [async-threads:0]
>>
>> Eshell V5.5.4  (abort with ^G)
>> 1> c("test7705.erl").
>> {ok,test7705}
>> 2> test7705:header().
>> <<"\btest7705">>
>> 3> erl_tidy:file("test7705.erl").
>> ok
>> 4> c("test7705.erl").
>> ./test7705.erl:6: syntax error before: '('
>> ./test7705.erl:3: function header/0 undefined
>> error
>> 5>
>>
>> The reason for failure is that the parentheses around size(...) are 
>> omitted in pretty printing:
>> -module(test7705).
>>
>> -export([header/0]).
>>
>> header() ->
>>     Bin = <<"test7705">>, <<size(Bin), Bin/binary>>.
>>
>>
>> The cause of this is in erl_prettypr.erl around line 624. However, it 
>> is not obvious how to fix the code in the right way. Any suggestions?
>>
>> Thanks
>> Thomas
>> _______________________________________________
>> erlang-questions mailing list
>> erlang-questions@REDACTED
>> http://www.erlang.org/mailman/listinfo/erlang-questions
>>
> 
> 
> ------------------------------------------------------------------------
> 
> Index: lib/syntax_tools/src/erl_prettypr.erl
> ===================================================================
> RCS file: /hipe/otp/lib/syntax_tools/src/erl_prettypr.erl,v
> retrieving revision 1.56
> diff -u -r1.56 erl_prettypr.erl
> --- lib/syntax_tools/src/erl_prettypr.erl	28 Mar 2007 09:59:01 -0000	1.56
> +++ lib/syntax_tools/src/erl_prettypr.erl	13 Aug 2007 20:03:28 -0000
> @@ -640,7 +640,7 @@
>  		   beside(par(Es), floating(text(">>"))));
>  
>  	binary_field ->
> -	    Ctxt1 = reset_prec(Ctxt),
> +	    Ctxt1 = set_prec(Ctxt, max_prec()),
>  	    D1 = lay(erl_syntax:binary_field_body(Node), Ctxt1),
>  	    D2 = case erl_syntax:binary_field_types(Node) of
>  		     [] ->




More information about the erlang-questions mailing list