Hi,

2009/7/21 Mark Moseley <redmine / ruby-lang.org>:
> With the following code:
>
> 1: def foo
> 2:   a = 5
> 3:   return a
> 4: end
>
> No trace instruction is generated for line 3.
>
> If line 3 is just "a", without the return, then it functions as expected.


I think it is a parser's fault, not compiler's.
reduce_nodes (in parse.y) may incorrectly eliminate some nodes marked as
NODE_FL_NEWLINE.
The following patch preserves and propagates the mark.


Index: parse.y
===================================================================
--- parse.y	(revision 24580)
+++ parse.y	(working copy)
@@ -8406,6 +8406,7 @@
      (reduce_nodes(&node->n1), body = &node->n2, 1))

     while (node) {
+	int newline = node->flags & NODE_FL_NEWLINE;
 	switch (nd_type(node)) {
 	  end:
 	  case NODE_NIL:
@@ -8413,9 +8414,11 @@
 	    return;
 	  case NODE_RETURN:
 	    *body = node = node->nd_stts;
+	    if (newline && node) node->flags |= NODE_FL_NEWLINE;
 	    continue;
 	  case NODE_BEGIN:
 	    *body = node = node->nd_body;
+	    if (newline && node) node->flags |= NODE_FL_NEWLINE;
 	    continue;
 	  case NODE_BLOCK:
 	    body = &node->nd_end->nd_head;
@@ -8439,6 +8442,7 @@
 	    return;
 	}
 	node = *body;
+	if (newline && node) node->flags |= NODE_FL_NEWLINE;
     }

 #undef subnodes


I did not completely understand your patch (http://gist.github.com/166330).
`last_line_traced' seems to be a workaround against the above bug, then
to be no longer needed.
But I couldn't understand why change in `compile_massign_lhs' was needed.

Is my above patch enough for you?  If not, could you elaborate the
situation you are facing?

-- 
Yusuke ENDOH <mame / tsg.ne.jp>