diff options
author | mame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-05-19 11:18:12 +0000 |
---|---|---|
committer | mame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-05-19 11:18:12 +0000 |
commit | 56036e3514a5afa76c60b7850277da63c4de93b1 (patch) | |
tree | f3b991bb86959c17df34c631e2440727795e939f /vm_eval.c | |
parent | 61086883b64312d8936fde7138d195e196d514a4 (diff) |
* vm_eval.c (rb_f_caller): return [] instead of nil when the function
is called on toplevel. [ruby-dev:41348]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27895 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'vm_eval.c')
-rw-r--r-- | vm_eval.c | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -1562,7 +1562,7 @@ rb_catch_obj(VALUE tag, VALUE (*func)(), VALUE data) static VALUE rb_f_caller(int argc, VALUE *argv) { - VALUE level; + VALUE level, ary; int lev; rb_scan_args(argc, argv, "01", &level); @@ -1574,7 +1574,9 @@ rb_f_caller(int argc, VALUE *argv) if (lev < 0) rb_raise(rb_eArgError, "negative level (%d)", lev); - return vm_backtrace(GET_THREAD(), lev); + ary = vm_backtrace(GET_THREAD(), lev); + if (NIL_P(ary)) ary = rb_ary_new(); + return ary; } static int |