anchor.diff:      [match_ivar(Line, Ivar) || Ivar <- Ivars],
       {identifier, Line, '__match_result'}
     ])}.
  -  
  +
  +% Store ivars from placeholder variables generated by the match expression  
   match_ivar(Line, Name) ->
     {match, Line, 
       {identifier, Line, '__instance_variables'},
  
positive.code: transform(State, Node) ->
    {walk, State, Node}.
    
  placeholder_name(Name) ->
    list_to_atom("__placeholder_" ++ atom_to_list(Name)).
    
  match_node(Line, Expr1, Expr2, []) ->
    {match, Line, Expr1, Expr2};
  match_node(Line, Expr1, Expr2, Ivars) ->
  
negative.code:   ),
    {stop, class, {function, Line, Name, Arguments, Expressions2}};
  
  % Match statements
  transform(method, {match, Line, In1, In2}) ->
    {ok, _, Out2} = reia_visitor:transform(In2, method, fun transform/2),
    {ok, {_, Ivars}, Out1} = reia_visitor:transform(In1, {match, sets:new()}, fun transform/2),
    {stop, method, match_node(Line, Out1, Out2, sets:to_list(Ivars))};
    
  % Instance variable matching
  transform({match, Ivars}, {ivar, Line, Name}) ->
    Ivars2 = sets:add_element(Name, Ivars),
    Node = {identifier, Line, placeholder_name(Name)},
    {stop, {match, Ivars2}, Node};
    
  % Instance variable lookup
  transform(method, {ivar, Line, Name}) ->
    Node = {'case', Line,
      % Use dict:find to retrieve the ivar
      {call, Line,
        {remote, Line, {atom, Line, dict}, {atom, Line, find}},
        [{atom, Line, Name}, {identifier, Line, '__instance_variables'}]
      },
      [
        {clause, Line, 
          {tuple, Line, [{atom, Line, 'ok'}, {identifier, Line, placeholder_name(Name)}]},
          [{identifier, Line, placeholder_name(Name)}]
        },
        {clause, Line, {atom, Line, 'error'}, [{atom, Line, nil}]}
      ]
    },
    {stop, method, Node};
    
  % Instance variables used outside of classes
  transform(_State, {ivar, Line, _Name}) ->
    throw({error, {Line, "instance variables can only be referenced in classes"}});
        
  