summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--parse.y8
-rw-r--r--test/ruby/test_lambda.rb24
-rw-r--r--version.h2
4 files changed, 35 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index f20c030465..683cfe00fe 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Fri Sep 27 01:11:21 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * parse.y (lambda): adjust position to the beginning of the block.
+
Fri Sep 27 01:02:59 2013 NARUSE, Yui <naruse@ruby-lang.org>
* lib/uri/generic.rb (URI::Generic.find_proxy): return nil if
diff --git a/parse.y b/parse.y
index 01db8bdd44..4a4fb12cb7 100644
--- a/parse.y
+++ b/parse.y
@@ -3462,13 +3462,17 @@ lambda : {
lpar_beg = ++paren_nest;
}
f_larglist
+ {
+ $<num>$ = ruby_sourceline;
+ }
lambda_body
{
lpar_beg = $<num>2;
/*%%%*/
- $$ = NEW_LAMBDA($3, $4);
+ $$ = NEW_LAMBDA($3, $5);
+ nd_set_line($$, $<num>4);
/*%
- $$ = dispatch2(lambda, $3, $4);
+ $$ = dispatch2(lambda, $3, $5);
%*/
dyna_pop($<vars>1);
}
diff --git a/test/ruby/test_lambda.rb b/test/ruby/test_lambda.rb
index 40bd134e2f..175183d847 100644
--- a/test/ruby/test_lambda.rb
+++ b/test/ruby/test_lambda.rb
@@ -89,4 +89,28 @@ class TestLambdaParameters < Test::Unit::TestCase
assert_send([e.backtrace.first, :start_with?, "#{__FILE__}:#{line}:"], bug6151)
assert_equal(0, called)
end
+
+ def test_do_lambda_source_location
+ exp_lineno = __LINE__ + 3
+ lmd = ->(x,
+ y,
+ z) do
+ #
+ end
+ file, lineno = lmd.source_location
+ assert_match(/^#{ Regexp.quote(__FILE__) }$/, file)
+ assert_equal(exp_lineno, lineno, "must be at the beginning of the block")
+ end
+
+ def test_brace_lambda_source_location
+ exp_lineno = __LINE__ + 3
+ lmd = ->(x,
+ y,
+ z) {
+ #
+ }
+ file, lineno = lmd.source_location
+ assert_match(/^#{ Regexp.quote(__FILE__) }$/, file)
+ assert_equal(exp_lineno, lineno, "must be at the beginning of the block")
+ end
end
diff --git a/version.h b/version.h
index 7002a85c44..83615db035 100644
--- a/version.h
+++ b/version.h
@@ -1,6 +1,6 @@
#define RUBY_VERSION "2.0.0"
#define RUBY_RELEASE_DATE "2013-09-27"
-#define RUBY_PATCHLEVEL 319
+#define RUBY_PATCHLEVEL 320
#define RUBY_RELEASE_YEAR 2013
#define RUBY_RELEASE_MONTH 9