summaryrefslogtreecommitdiff
path: root/variable.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-02-18 14:30:17 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-02-18 14:30:17 +0000
commitddd9d609dca9844e1d62ef4dd58f5d62c9bebc0b (patch)
tree1cdebfa2fe2170d793fd70ece0e7dd9d97d1ede5 /variable.c
parentb4f940b76799a3cdcc5a39f34dfadd76e83bbd2f (diff)
* 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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3504 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'variable.c')
-rw-r--r--variable.c25
1 files changed, 22 insertions, 3 deletions
diff --git a/variable.c b/variable.c
index 4a7bcd4..9ac004e 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,12 +985,30 @@ 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;
ID id;