anchor.diff:  fetch_ref(Name, [{{msg,Name}=Key,_} | _])  -> Key;
   fetch_ref(Name, [_ | T])                   -> fetch_ref(Name, T).
   
  +%% `Defs' is expected to be flattened
  +enumerate_msg_fields(Defs) ->
  +    lists:map(fun({{msg,Name}, Fields}) ->
  +                      {{msg, Name}, enumerate_fields(Fields)};
  +                 (OtherElem) ->
  +                      OtherElem
  +              end,
  +              Defs).
  +
  +enumerate_fields(Fields) ->
  +    lists:map(fun({I, #field{}=F}) -> F#field{rnum=I} end,
  +              index_seq(2, Fields)).
  +
  +index_seq(_Start, []) -> [];
  +index_seq(Start, L)   -> lists:zip(lists:seq(Start, length(L) + Start - 1), L).
  +
   %% `Defs' is expected to be parsed.
   fetch_imports(Defs) ->
       [Path || {import,Path} <- Defs].
  
positive.code:         lists:sort(
            resolve_refs(reformat_names(flatten_defs(absolutify_names(Elems))))).
  
  fetches_imports_test() ->
      {ok, Elems} = parse_lines(["package p1;"
                                 "import \"a/b/c.proto\";",
  
negative.code: -export([verify_refs/1]).
  -export([reformat_names/1]).
  -export([resolve_refs/1]).
  -export([enumerate_msg_fields/1]).
  -export([fetch_imports/1]).
  
  
  