[前][次][番号順一覧][スレッド一覧]

ruby-changes:14174

From: nobu <ko1@a...>
Date: Fri, 4 Dec 2009 16:51:59 +0900 (JST)
Subject: [ruby-changes:14174] Ruby:r25992 (trunk): * parse.y (k_def): adjust the location of method definition to the

nobu	2009-12-04 16:50:15 +0900 (Fri, 04 Dec 2009)

  New Revision: 25992

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=25992

  Log:
    * parse.y (k_def): adjust the location of method definition to the
      line of def.  [Bug #2427]

  Modified files:
    trunk/ChangeLog
    trunk/parse.y
    trunk/test/ruby/test_proc.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 25991)
+++ ChangeLog	(revision 25992)
@@ -1,3 +1,8 @@
+Fri Dec  4 16:50:13 2009  Nobuyoshi Nakada  <nobu@r...>
+
+	* parse.y (k_def): adjust the location of method definition to the
+	  line of def.  [Bug #2427]
+
 Fri Dec  4 15:50:18 2009  Shugo Maeda  <shugo@r...>
 
 	* vm_eval.c (yield_under): does not yield self, and passes blockptr
Index: parse.y
===================================================================
--- parse.y	(revision 25991)
+++ parse.y	(revision 25992)
@@ -2902,7 +2902,7 @@
 			NODE *body = remove_begin($5);
 			reduce_nodes(&body);
 			$$ = NEW_DEFN($2, $4, body, NOEX_PRIVATE);
-			fixpos($$, $4);
+			nd_set_line($$, $<num>1);
 		    /*%
 			$$ = dispatch3(def, $2, $4, $5);
 		    %*/
@@ -2924,7 +2924,7 @@
 			NODE *body = remove_begin($8);
 			reduce_nodes(&body);
 			$$ = NEW_DEFS($2, $5, $7, body);
-			fixpos($$, $2);
+			nd_set_line($$, $<num>1);
 		    /*%
 			$$ = dispatch5(defs, $2, $3, $5, $7, $8);
 		    %*/
@@ -3034,6 +3034,10 @@
 k_def		: keyword_def
 		    {
 			token_info_push("def");
+		    /*%%%*/
+			$<num>$ = ruby_sourceline;
+		    /*%
+		    %*/
 		    }
 		;
 
Index: test/ruby/test_proc.rb
===================================================================
--- test/ruby/test_proc.rb	(revision 25991)
+++ test/ruby/test_proc.rb	(revision 25992)
@@ -746,14 +746,15 @@
     assert(x.to_s.tainted?)
   end
 
-  def source_location_test
-    __LINE__
+  @@line_of_source_location_test = __LINE__ + 1
+  def source_location_test a=1,
+    b=2
   end
 
   def test_source_location
     file, lineno = method(:source_location_test).source_location
     assert_match(/^#{ Regexp.quote(__FILE__) }$/, file)
-    assert_equal(source_location_test - 1, lineno)
+    assert_equal(@@line_of_source_location_test, lineno, 'Bug #2427')
   end
 
   def test_splat_without_respond_to

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]