Skip to content

Commit

Permalink
* eval.c (rb_call0): should not report uninitialized warning by
Browse files Browse the repository at this point in the history
  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.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3504 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
matz committed Feb 18, 2003
1 parent b4f940b commit ddd9d60
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 4 deletions.
10 changes: 10 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
Tue Feb 18 21:39:27 2003 Yukihiro Matsumoto <[email protected]>

* 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 <[email protected]>

* misc/ruby-mode.el (ruby-comment-column): customize comment
Expand Down
3 changes: 3 additions & 0 deletions eval.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion intern.h
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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*));
Expand Down
1 change: 1 addition & 0 deletions io.c
Original file line number Diff line number Diff line change
Expand Up @@ -3698,6 +3698,7 @@ argf_fileno()
static VALUE
argf_to_io()
{
next_argv();
return current_file;
}

Expand Down
25 changes: 22 additions & 3 deletions variable.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
Expand Down

0 comments on commit ddd9d60

Please sign in to comment.