[erlang-bugs] Bug in expansion of ?LINE macro

Hans Bolinder <>
Wed Dec 3 17:20:00 CET 2008


[John Hughes:]
> Given this macro definition:
> 
> -define(RECEIVE(Msg,Body),
>      receive
>          Msg -> Body;
>          M ->
>               exit({unexpected_message,M,on_line,?LINE,was_expecting,??Msg})
>      after 10000 ->
>           exit({timeout,on_line,?LINE,was_expecting,??Msg})
>      end).
> 
> the first occurrence of ?LINE expands to the line number on which ?RECEIVE 
> appears, but the second occurrence of ?LINE expands to 1.

Thanks for the bug report.

We'll fix the problem in R13A.

Best regards,

Hans Bolinder, Erlang/OTP team, Ericsson



*** /usr/local/otp/releases/otp_beam_linux_sles10_x64_r12b_patched/lib/stdlib-1.15.5/src/epp.erl	Thu Nov  6 12:10:07 2008
--- epp.erl	Wed Dec  3 16:21:01 2008
***************
*** 870,876 ****
      case dict:find(V, Bs) of
  	{ok,Val} ->
  	    %% lists:append(Val, expand_macro(Ts, L, Rest, Bs));
! 	    expand_arg(stringify(Val), Ts, L, Rest, Bs);
  	error ->
  	    [{var,L,V}|expand_macro(Ts, L, Rest, Bs)]
      end;
--- 870,876 ----
      case dict:find(V, Bs) of
  	{ok,Val} ->
  	    %% lists:append(Val, expand_macro(Ts, L, Rest, Bs));
! 	    expand_arg(stringify(Val, L), Ts, L, Rest, Bs);
  	error ->
  	    [{var,L,V}|expand_macro(Ts, L, Rest, Bs)]
      end;
***************
*** 907,915 ****
  stringify1([T | Tokens]) ->
      [io_lib:format(" ~s", [token_src(T)]) | stringify1(Tokens)].
  
! stringify(L) ->
!     [$\s | S] = lists:flatten(stringify1(L)),
!     [{string, 1, S}].
  
  %% epp_request(Epp)
  %% epp_request(Epp, Request)
--- 907,915 ----
  stringify1([T | Tokens]) ->
      [io_lib:format(" ~s", [token_src(T)]) | stringify1(Tokens)].
  
! stringify(Ts, L) ->
!     [$\s | S] = lists:flatten(stringify1(Ts)),
!     [{string, L, S}].
  
  %% epp_request(Epp)
  %% epp_request(Epp, Request)



More information about the erlang-bugs mailing list