1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* vm_insnhelper.c (argument_error): use line number at the beginning

of lambda, not the first code ob its body.
  [ruby-core:43314][Bug #6151]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35052 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2012-03-16 03:00:44 +00:00
parent e2ca7837d1
commit 817eb7d17d
3 changed files with 25 additions and 6 deletions

View file

@ -1,4 +1,8 @@
Fri Mar 16 11:59:56 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
Fri Mar 16 12:00:42 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
* vm_insnhelper.c (argument_error): use line number at the beginning
of lambda, not the first code ob its body.
[ruby-core:43314][Bug #6151]
* iseq.c (rb_iseq_first_lineno): constified.

View file

@ -70,4 +70,23 @@ class TestLambdaParameters < Test::Unit::TestCase
BasicObject.new.instance_eval {->() {called = true}.()}
assert_equal(true, called, bug5966)
end
def test_location_on_error
bug6151 = '[ruby-core:43314]'
called = 0
line, f = __LINE__, lambda do
called += 1
true
end
e = assert_raise(ArgumentError) do
f.call(42)
end
assert_send([e.backtrace.first, :start_with?, "#{__FILE__}:#{line}:"], bug6151)
assert_equal(0, called)
e = assert_raise(ArgumentError) do
42.times(&f)
end
assert_send([e.backtrace.first, :start_with?, "#{__FILE__}:#{line}:"], bug6151)
assert_equal(0, called)
end
end

View file

@ -130,11 +130,7 @@ argument_error(const rb_iseq_t *iseq, int miss_argc, int min_argc, int max_argc)
VALUE err_line = 0;
if (iseq) {
int line_no = 1;
if (iseq->line_info_size) {
line_no = iseq->line_info_table[0].line_no;
}
int line_no = rb_iseq_first_lineno(iseq);
err_line = rb_sprintf("%s:%d:in `%s'",
RSTRING_PTR(iseq->filename),