anchor.diff:         = Avp,
          {Rec, AM, Failed}) ->
       T = Mod:avp_name(Code, Vid),
  -    decode(Name, Opts, Mod, T, Avp, {Rec, incr(field(T), AM), Failed}).
  +    F = field(T),
  +    A = Mod:avp_arity(Name, F),
  +    decode(Name, Opts, Mod, T, A, Avp, {Rec, incr(field(F, A), AM), Failed}).
   
   %% field/1
   
  -field({AvpName, _Type}) ->
  +field({AvpName, _}) ->
       AvpName;
   
  -field('AVP' = A) ->
  -    A.
  +field(_) ->
  +    'AVP'.
  +
  +%% field/2
  +
  +field(_, 0) ->
  +    'AVP';
  +
  +field(F, _) ->
  +    F.
   
   %% incr/2
   
  
positive.code: %%      Failed-AVP AVP MUST be included and contain a copy of the
  %%      offending AVP.
  
  %% pack_arity/4
  
  %% Give Failed-AVP special treatment since (1) it'll contain any
  %% unrecognized mandatory AVP's and (2) the RFC 3588 grammar failed to
  %% allow for Failed-AVP in an answer-message.
  
  pack_arity(Name,
             #{strict_mbit := Strict,
               failed_avp := Failed},
             Mod,
             #diameter_avp{is_mandatory = M,
                           name = AvpName}) ->
  
      %% Not testing just Name /= 'Failed-AVP' means we're changing the
      %% packing of AVPs nested within Failed-AVP, but the point of
  
negative.code:     %% possible, and failing because a mandatory AVP couldn't be
      %% packed into a dedicated field defeats that point.
  
      0 < Arity andalso (Failed == true
                         orelse Name == 'Failed-AVP'
                         orelse (Name == 'answer-message'
                                 andalso AvpName == 'Failed-AVP')
                         orelse not M
                         orelse not Strict).
  
  %% pack/5
  
  pack(Arity, F, Avp, Mod, {Rec, AM, Failed}) ->
      {set(Arity, F, value(F, Avp), Mod, Rec), AM, Failed}.
  
  %% set/5
  
  