summaryrefslogtreecommitdiff
path: root/vm_eval.c
diff options
context:
space:
mode:
authormame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-05-19 11:18:12 +0000
committermame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-05-19 11:18:12 +0000
commit56036e3514a5afa76c60b7850277da63c4de93b1 (patch)
treef3b991bb86959c17df34c631e2440727795e939f /vm_eval.c
parent61086883b64312d8936fde7138d195e196d514a4 (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.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/vm_eval.c b/vm_eval.c
index 2bf640d978..d1e6352e03 100644
--- a/vm_eval.c
+++ b/vm_eval.c
@@ -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