From 8603c5934a4e613cdb07b04a1ce86fb1f21fdbd5 Mon Sep 17 00:00:00 2001 From: nobu Date: Tue, 26 Jul 2011 16:05:35 +0000 Subject: * eval_error.c (rb_print_undef_str): new function to raise NameError for undefined method. * load.c (rb_mod_autoload_p), object.c (rb_mod_const_get), variable.c (rb_f_untrace_var, set_const_visibility), vm_method.c (rb_mod_{remove,undef,alias}_method, set_method_visibility): remove inadvertent symbol creation. based on the first patch by Jeremy Evans at [ruby-core:38447]. [Feature #5089] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32686 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- variable.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'variable.c') diff --git a/variable.c b/variable.c index b3842c85c0..f1dc8f41ae 100644 --- a/variable.c +++ b/variable.c @@ -634,7 +634,10 @@ rb_f_untrace_var(int argc, VALUE *argv) rb_secure(4); rb_scan_args(argc, argv, "11", &var, &cmd); - id = rb_to_id(var); + id = rb_check_id(&var); + if (!id) { + rb_name_error_str(var, "undefined global variable %s", RSTRING_PTR(var)); + } if (!st_lookup(rb_global_tbl, (st_data_t)id, &data)) { rb_name_error(id, "undefined global variable %s", rb_id2name(id)); } @@ -1972,7 +1975,11 @@ set_const_visibility(VALUE mod, int argc, VALUE *argv, rb_const_flag_t flag) } for (i = 0; i < argc; i++) { - id = rb_to_id(argv[i]); + VALUE val = argv[i]; + id = rb_check_id(&val); + if (!id) { + rb_name_error_str(val, "constant %s::%s not defined", rb_class2name(mod), RSTRING_PTR(val)); + } if (RCLASS_CONST_TBL(mod) && st_lookup(RCLASS_CONST_TBL(mod), (st_data_t)id, &v)) { ((rb_const_entry_t*)v)->flag = flag; return; -- cgit v1.2.3