Skip to content

Commit

Permalink
* eval.c (rb_f_missing): NoMethod error messages for true, false,
Browse files Browse the repository at this point in the history
  nil must respond visibility like for other objects.


git-svn-id: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_6@2144 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
matz committed Feb 27, 2002
1 parent 3ced3c5 commit 3ac7ff9
Show file tree
Hide file tree
Showing 8 changed files with 131 additions and 97 deletions.
9 changes: 9 additions & 0 deletions ChangeLog
@@ -1,3 +1,7 @@
Wed Feb 27 13:49:24 2002 Yukihiro Matsumoto <matz@ruby-lang.org>

* stable version 1.6.6 released.

Wed Feb 27 13:18:49 2002 WATANABE Hirofumi <eban@ruby-lang.org>

* io.c (READ_DATA_PENDING): uClibc support.
Expand All @@ -19,6 +23,11 @@ Tue Feb 26 21:36:01 2002 Usaku Nakamura <usa@ruby-lang.org>

* bignum.c (rb_big_2comp): void function cannot return any value.

Tue Feb 26 16:52:12 2002 Yukihiro Matsumoto <matz@ruby-lang.org>

* eval.c (rb_f_missing): NoMethod error messages for true, false,
nil must respond visibility like for other objects.

Tue Feb 26 11:25:50 2002 akira yamada <akira@arika.org>

* lib/uri/generic.rb: merge0 shuld return [oth, oth] if oth is
Expand Down
47 changes: 24 additions & 23 deletions eval.c
Expand Up @@ -4082,7 +4082,7 @@ rb_f_missing(argc, argv, obj)
VALUE *argv;
VALUE obj;
{
ID id;
ID id, noclass;
volatile VALUE d = 0;
char *format = 0;
char *desc = "";
Expand All @@ -4096,17 +4096,16 @@ rb_f_missing(argc, argv, obj)
rb_stack_check();

id = SYM2ID(argv[0]);
argc--; argv++;

switch (TYPE(obj)) {
case T_NIL:
format = "undefined method `%s' for nil";
desc = "nil";
break;
case T_TRUE:
format = "undefined method `%s' for true";
desc = "true";
break;
case T_FALSE:
format = "undefined method `%s' for false";
desc = "false";
break;
case T_OBJECT:
d = rb_any_to_s(obj);
Expand All @@ -4116,36 +4115,38 @@ rb_f_missing(argc, argv, obj)
break;
}
if (d) {
if (last_call_status & CSTAT_PRIV) {
format = "private method `%s' called for %s%s%s";
}
if (last_call_status & CSTAT_PROT) {
format = "protected method `%s' called for %s%s%s";
}
else if (last_call_status & CSTAT_VCALL) {
const char *mname = rb_id2name(id);

if (('a' <= mname[0] && mname[0] <= 'z') || mname[0] == '_') {
format = "undefined local variable or method `%s' for %s%s%s";
}
}
if (!format) {
format = "undefined method `%s' for %s%s%s";
}
if (RSTRING(d)->len > 65) {
d = rb_any_to_s(obj);
}
desc = RSTRING(d)->ptr;
}

if (last_call_status & CSTAT_PRIV) {
format = "private method `%s' called for %s%s%s";
}
if (last_call_status & CSTAT_PROT) {
format = "protected method `%s' called for %s%s%s";
}
else if (last_call_status & CSTAT_VCALL) {
const char *mname = rb_id2name(id);

if (('a' <= mname[0] && mname[0] <= 'z') || mname[0] == '_') {
format = "undefined local variable or method `%s' for %s%s%s";
}
}
if (!format) {
format = "undefined method `%s' for %s%s%s";
}

ruby_sourcefile = file;
ruby_sourceline = line;
PUSH_FRAME(); /* fake frame */
*ruby_frame = *_frame.prev->prev;

noclass = (!d || desc[0]=='#');
rb_raise(rb_eNameError, format, rb_id2name(id),
desc, desc[0]=='#'?"":":",
desc[0]=='#'?"":rb_class2name(CLASS_OF(obj)));
desc, noclass ? "" : ":",
noclass ? "" : rb_class2name(CLASS_OF(obj)));
POP_FRAME();

return Qnil; /* not reached */
Expand Down
18 changes: 9 additions & 9 deletions intern.h
Expand Up @@ -95,13 +95,13 @@ VALUE rb_class_instance_methods _((int, VALUE*, VALUE));
VALUE rb_class_protected_instance_methods _((int, VALUE*, VALUE));
VALUE rb_class_private_instance_methods _((int, VALUE*, VALUE));
VALUE rb_obj_singleton_methods _((VALUE));
void rb_define_method_id _((VALUE, ID, VALUE (*)(), int));
void rb_define_method_id _((VALUE, ID, VALUE (*)(ANYARGS), int));
void rb_frozen_class_p _((VALUE));
void rb_undef _((VALUE, ID));
void rb_define_protected_method _((VALUE, const char*, VALUE (*)(), int));
void rb_define_private_method _((VALUE, const char*, VALUE (*)(), int));
void rb_define_singleton_method _((VALUE,const char*,VALUE(*)(),int));
void rb_define_private_method _((VALUE,const char*,VALUE(*)(),int));
void rb_define_protected_method _((VALUE, const char*, VALUE (*)(ANYARGS), int));
void rb_define_private_method _((VALUE, const char*, VALUE (*)(ANYARGS), int));
void rb_define_singleton_method _((VALUE,const char*,VALUE(*)(ANYARGS),int));
void rb_define_private_method _((VALUE,const char*,VALUE(*)(ANYARGS),int));
VALUE rb_singleton_class _((VALUE));
/* enum.c */
VALUE rb_enum_length _((VALUE));
Expand Down Expand Up @@ -167,13 +167,13 @@ void rb_thread_sleep_forever _((void));
VALUE rb_thread_stop _((void));
VALUE rb_thread_wakeup _((VALUE));
VALUE rb_thread_run _((VALUE));
VALUE rb_thread_create _((VALUE (*)(), void*));
VALUE rb_thread_create _((VALUE (*)(ANYARGS), void*));
int rb_thread_scope_shared_p _((void));
void rb_thread_interrupt _((void));
void rb_thread_trap_eval _((VALUE, int));
void rb_thread_signal_raise _((char*));
int rb_thread_select();
void rb_thread_wait_for();
int rb_thread_select(ANYARGS);
void rb_thread_wait_for(ANYARGS);
VALUE rb_thread_current _((void));
VALUE rb_thread_main _((void));
VALUE rb_thread_local_aref _((VALUE, ID));
Expand Down Expand Up @@ -351,7 +351,7 @@ VALUE rb_struct_aref _((VALUE, VALUE));
VALUE rb_struct_aset _((VALUE, VALUE, VALUE));
VALUE rb_struct_getmember _((VALUE, ID));
/* time.c */
VALUE rb_time_new();
VALUE rb_time_new(ANYARGS);
/* variable.c */
VALUE rb_mod_name _((VALUE));
VALUE rb_class_path _((VALUE));
Expand Down

0 comments on commit 3ac7ff9

Please sign in to comment.