[Parsetree] patch for op_asgn1

Topher Cyll christophercyll at gmail.com
Fri Sep 8 17:54:26 PDT 2006


Hi,

I noticed it's currently impossible to distinguish the op_asgn1 node
for the following two expressions:

a['foo'] += 1
a['foo'] -= 1

The following patch to parse_tree.rb (which I'm sending inline since
cut and paste probably makes more sense than patch) adds the operator
symbol to the sexp:

   case NODE_OP_ASGN1:
     add_to_parse_tree(current, node->nd_recv, newlines, locals);
     add_to_parse_tree(current, node->nd_args->nd_next, newlines, locals);
+    rb_ary_push(current, ID2SYM(node->nd_mid));
     add_to_parse_tree(current, node->nd_args->nd_head, newlines, locals);
     break;

What do you think?

Topher


More information about the Parsetree mailing list