summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog8
-rw-r--r--eval.c4
-rw-r--r--lib/delegate.rb2
-rw-r--r--numeric.c6
-rw-r--r--object.c7
-rw-r--r--re.c6
-rw-r--r--string.c1
-rw-r--r--variable.c11
8 files changed, 34 insertions, 11 deletions
diff --git a/ChangeLog b/ChangeLog
index b2585a46280..591fe85ab23 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+Wed Apr 8 00:59:13 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * variable.c (rb_const_defined): returned false even if the
+ constant is defined at the top level.
+
+ * eval.c (f_local_variables): dyna_var->id may be null. should
+ have checked before calling str_new2().
+
Tue Apr 7 18:50:16 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
* experimental release 1.1b9_08.
diff --git a/eval.c b/eval.c
index 091e2ef7faf..412f0b9db97 100644
--- a/eval.c
+++ b/eval.c
@@ -4462,7 +4462,9 @@ f_local_variables()
vars = the_dyna_vars;
while (vars) {
- ary_push(ary, str_new2(rb_id2name(vars->id)));
+ if (vars->id) {
+ ary_push(ary, str_new2(rb_id2name(vars->id)));
+ }
vars = vars->next;
}
diff --git a/lib/delegate.rb b/lib/delegate.rb
index a5447739836..a4bbe0615c3 100644
--- a/lib/delegate.rb
+++ b/lib/delegate.rb
@@ -47,7 +47,7 @@ class SimpleDelegator<Delegator
end
end
-# backword compatibility ^_^;;;
+# backward compatibility ^_^;;;
Delegater = Delegator
SimpleDelegater = SimpleDelegator
diff --git a/numeric.c b/numeric.c
index f5b0fc24fe7..ea90e035882 100644
--- a/numeric.c
+++ b/numeric.c
@@ -52,6 +52,8 @@ coerce_rescue(x)
VALUE *x;
{
TypeError("%s can't be coerced into %s",
+ rb_special_const_p(x[1])?
+ STR2CSTR(rb_inspect(x[1])):
rb_class2name(CLASS_OF(x[1])),
rb_class2name(CLASS_OF(x[0])));
}
@@ -643,6 +645,10 @@ num2int(val)
TypeError("no implicit conversion from string");
return Qnil; /* not reached */
+ case T_NIL:
+ TypeError("no implicit conversion from nil");
+ return Qnil; /* not reached */
+
default:
val = rb_rescue(to_integer, val, fail_to_integer, val);
if (!obj_is_kind_of(val, cInteger)) {
diff --git a/object.c b/object.c
index fa7c3b05c59..fa553912608 100644
--- a/object.c
+++ b/object.c
@@ -289,6 +289,7 @@ nil_plus(x, y)
VALUE x, y;
{
switch (TYPE(y)) {
+ case T_NIL:
case T_FIXNUM:
case T_FLOAT:
case T_BIGNUM:
@@ -297,7 +298,8 @@ nil_plus(x, y)
return y;
default:
TypeError("tried to add %s(%s) to nil",
- RSTRING(obj_as_string(y))->ptr, rb_class2name(CLASS_OF(y)));
+ STR2CSTR(rb_inspect(y)),
+ rb_class2name(CLASS_OF(y)));
}
/* not reached */
}
@@ -722,6 +724,9 @@ f_integer(obj, arg)
case T_STRING:
return str2inum(RSTRING(arg)->ptr, 0);
+ case T_NIL:
+ return INT2FIX(0);
+
default:
i = NUM2INT(arg);
}
diff --git a/re.c b/re.c
index b34e5e6fc57..262b716c1aa 100644
--- a/re.c
+++ b/re.c
@@ -883,7 +883,7 @@ reg_regsub(str, src, regs)
char *ss = s;
c = *s++;
- if (c != '\\') continue;
+ if (c != '\\' || s == e) continue;
if (!val) val = str_new(p, ss-p);
else str_cat(val, p, ss-p);
@@ -913,10 +913,6 @@ reg_regsub(str, src, regs)
if (no == 0) continue;
break;
- case '\\':
- str_cat(val, s-1, 1);
- continue;
-
default:
str_cat(val, s-2, 2);
continue;
diff --git a/string.c b/string.c
index 1d3cdadc7cc..1b4a984ad35 100644
--- a/string.c
+++ b/string.c
@@ -429,6 +429,7 @@ str_concat(str1, str2)
#if 0
str2 = obj_as_string(str2);
#else
+ if (NIL_P(str2)) return str1;
Check_Type(str2, T_STRING);
#endif
str_cat(str1, RSTRING(str2)->ptr, RSTRING(str2)->len);
diff --git a/variable.c b/variable.c
index 24e66a6b56c..ef4b49e60dc 100644
--- a/variable.c
+++ b/variable.c
@@ -967,11 +967,16 @@ rb_const_defined(klass, id)
VALUE klass;
ID id;
{
- while (klass) {
- if (RCLASS(klass)->iv_tbl && st_lookup(RCLASS(klass)->iv_tbl, id, 0)) {
+ VALUE tmp = klass;
+
+ while (tmp) {
+ if (RCLASS(tmp)->iv_tbl && st_lookup(RCLASS(tmp)->iv_tbl,id,0)) {
return TRUE;
}
- klass = RCLASS(klass)->super;
+ tmp = RCLASS(tmp)->super;
+ }
+ if (BUILTIN_TYPE(klass) == T_MODULE) {
+ return rb_const_defined(cObject, id);
}
if (st_lookup(class_tbl, id, 0))
return TRUE;