diff --git a/ChangeLog b/ChangeLog index 55feaee634..05012a179d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +Tue Feb 18 21:39:27 2003 Yukihiro Matsumoto + + * eval.c (rb_call0): should not report uninitialized warning by + attribute reader method. + + * variable.c (rb_attr_get): new function to get instance variable + without uninitialized warning. + + * io.c (argf_to_io): should prefetch argv. + Tue Feb 18 00:13:50 2003 Nobuyoshi Nakada * misc/ruby-mode.el (ruby-comment-column): customize comment diff --git a/eval.c b/eval.c index ff1eeb59bf..cf56536d3c 100644 --- a/eval.c +++ b/eval.c @@ -4629,6 +4629,9 @@ rb_call0(klass, recv, id, oid, argc, argv, body, nosuper) if (argc != 0) { rb_raise(rb_eArgError, "wrong number of arguments(%d for 0)", argc); } + result = rb_attr_get(recv, body->nd_vid); + break; + case NODE_ATTRSET: /* for re-scoped/renamed method */ case NODE_ZSUPER: diff --git a/intern.h b/intern.h index f630c84162..4b1071373a 100644 --- a/intern.h +++ b/intern.h @@ -119,7 +119,6 @@ void rb_undef _((VALUE, ID)); 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)); /* compar.c */ int rb_cmpint _((VALUE)); @@ -437,6 +436,7 @@ VALUE rb_ivar_set _((VALUE, ID, VALUE)); VALUE rb_ivar_defined _((VALUE, ID)); VALUE rb_iv_set _((VALUE, const char*, VALUE)); VALUE rb_iv_get _((VALUE, const char*)); +VALUE rb_attr_get _((VALUE, ID)); VALUE rb_obj_instance_variables _((VALUE)); VALUE rb_obj_remove_instance_variable _((VALUE, VALUE)); void *rb_mod_const_at _((VALUE, void*)); diff --git a/io.c b/io.c index d4baa9f774..2f47e5f818 100644 --- a/io.c +++ b/io.c @@ -3698,6 +3698,7 @@ argf_fileno() static VALUE argf_to_io() { + next_argv(); return current_file; } diff --git a/variable.c b/variable.c index 4a7bcd4ee5..9ac004e7f5 100644 --- a/variable.c +++ b/variable.c @@ -965,10 +965,11 @@ rb_copy_generic_ivar(clone, obj) } } -VALUE -rb_ivar_get(obj, id) +static VALUE +ivar_get(obj, id, warn) VALUE obj; ID id; + int warn; { VALUE val; @@ -984,11 +985,29 @@ rb_ivar_get(obj, id) return generic_ivar_get(obj, id); break; } - rb_warning("instance variable %s not initialized", rb_id2name(id)); + if (warn && ruby_verbose) { + rb_warning("instance variable %s not initialized", rb_id2name(id)); + } return Qnil; } +VALUE +rb_ivar_get(obj, id) + VALUE obj; + ID id; +{ + return ivar_get(obj, id, Qtrue); +} + +VALUE +rb_attr_get(obj, id) + VALUE obj; + ID id; +{ + return ivar_get(obj, id, Qfalse); +} + VALUE rb_ivar_set(obj, id, val) VALUE obj;