anchor.diff:  
   %% failed_avp/3
   
  -failed_avp(_, [] = No, _) ->
  -    No;
  -
  -failed_avp(Rec, Avps, Dict) ->
  -    [failed(Rec, [{'AVP', Avps}], Dict)].
  +failed_avp(Msg, [_|_] = Avps, Dict) ->
  +    [failed(Msg, [{'AVP', Avps}], Dict)].
   
   %% Reply as name and tuple list ...
   failed([MsgName | Values], FailedAvp, Dict) ->
  
positive.code: %%   indicated by the Result-Code AVP.  For practical purposes, this
  %%   Failed-AVP would typically refer to the first AVP processing error
  %%   that a Diameter node encounters.
  
  select_error(Msg, Es, Dict0) ->
      {RC, Avps} = lists:foldl(fun(T,A) -> select(T, A, Dict0) end,
                               {is_answer_message(Msg, Dict0), []},
                               Es),
      {RC, lists:reverse(Avps)}.
  
  %% Only integer() and {integer(), #diameter_avp{}} are the result of
  %% decode. #diameter_avp{} can only be set in a reply for encode.
  
  select(#diameter_avp{} = A, {RC, As}, _) ->
      {RC, [A|As]};
  
  select(_, {RC, _} = Acc, _)
    when is_integer(RC) ->
      Acc;
  
  select({RC, #diameter_avp{} = A}, {IsAns, As} = Acc, Dict0)
    when is_integer(RC) ->
      case is_result(RC, IsAns, Dict0) of
          true  -> {RC, [A|As]};
          false -> Acc
      end;
  
  select(RC, {IsAns, As} = Acc, Dict0)
    when is_boolean(IsAns), is_integer(RC) ->
      case is_result(RC, IsAns, Dict0) of
          true  -> {RC, As};
          false -> Acc
      end.
  
  %% reset/4
  
  reset(Msg, Dict, RC, Avps) ->
      FailedAVP = failed_avp(Msg, Avps, Dict),
      ResultCode = rc(Msg, RC, Dict),
      set(set(Msg, FailedAVP, Dict), ResultCode, Dict).
  
  %% eval_packet/2
  
  eval_packet(Pkt, Fs) ->
      lists:foreach(fun(F) -> diameter_lib:eval([F,Pkt]) end, Fs).
  
  %% make_answer_packet/2
  
  %% Use decode errors to set Result-Code and/or Failed-AVP unless the
  %% the errors field has been explicitly set. Unfortunately, the
  
negative.code: %%
  %% Turn the result code into a list if its optional and only set it if
  %% the arity is 1 or {0,1}. In other cases (which probably shouldn't
  %% exist in practice) we can't know what's appropriate.
  
  rc([MsgName | _], RC, Dict) ->
      K = 'Result-Code',
  