aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog7
-rw-r--r--parse.y2
-rw-r--r--test/ruby/test_proc.rb14
3 files changed, 21 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 4438135d37..63c2524647 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Tue Apr 24 00:14:42 2012 Yusuke Endoh <mame@tsg.ne.jp>
+
+ * parse.y (primary): remove wrong "fixpos" that caused incorrect
+ source_location of blocks. [ruby-core:42232] [Bug #5930]
+
+ * test/ruby/test_proc.rb: add a test for above.
+
Mon Apr 23 22:56:08 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/iconv: deprecated. [Feature #6322]
diff --git a/parse.y b/parse.y
index e784e8b432..6de9cb36a4 100644
--- a/parse.y
+++ b/parse.y
@@ -2813,7 +2813,6 @@ primary : literal
/*%%%*/
$2->nd_iter = NEW_FCALL($1, 0);
$$ = $2;
- fixpos($2->nd_iter, $2);
/*%
$$ = method_arg(dispatch1(fcall, $1), arg_new());
$$ = method_add_block($$, $2);
@@ -2826,7 +2825,6 @@ primary : literal
block_dup_check($1->nd_args, $2);
$2->nd_iter = $1;
$$ = $2;
- fixpos($$, $1);
/*%
$$ = method_add_block($1, $2);
%*/
diff --git a/test/ruby/test_proc.rb b/test/ruby/test_proc.rb
index 686db844ee..3deb5c0109 100644
--- a/test/ruby/test_proc.rb
+++ b/test/ruby/test_proc.rb
@@ -1059,6 +1059,20 @@ class TestProc < Test::Unit::TestCase
assert_equal(@@line_of_attr_accessor_source_location_test, lineno)
end
+ def block_source_location_test(*args, &block)
+ block.source_location
+ end
+
+ def test_block_source_location
+ exp_lineno = __LINE__ + 3
+ file, lineno = block_source_location_test(1,
+ 2,
+ 3) do
+ end
+ assert_match(/^#{ Regexp.quote(__FILE__) }$/, file)
+ assert_equal(exp_lineno, lineno)
+ end
+
def test_splat_without_respond_to
def (obj = Object.new).respond_to?(m,*); false end
[obj].each do |a, b|