mirror of
https://github.com/ruby/ruby.git
synced 2025-08-23 13:04:13 +02:00
* hash.c (rb_any_cmp): should handle Qundef in keys.
* eval.c (remove_method): should not remove a empty method to implement "undef". * eval.c (rb_eval): should allow singleton class def for true/false/nil. * parse.y (str_extend): backslash escape was done wrong. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2102 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
dc7f9c1f89
commit
c46468d773
5 changed files with 36 additions and 10 deletions
27
eval.c
27
eval.c
|
@ -311,7 +311,7 @@ remove_method(klass, mid)
|
|||
rb_raise(rb_eSecurityError, "Insecure: can't remove method");
|
||||
}
|
||||
if (OBJ_FROZEN(klass)) rb_error_frozen("class/module");
|
||||
if (!st_delete(RCLASS(klass)->m_tbl, &mid, &body)) {
|
||||
if (!st_delete(RCLASS(klass)->m_tbl, &mid, &body) || !body->nd_body) {
|
||||
rb_name_error(mid, "method `%s' not defined in %s",
|
||||
rb_id2name(mid), rb_class2name(klass));
|
||||
}
|
||||
|
@ -3301,14 +3301,25 @@ rb_eval(self, n)
|
|||
{
|
||||
VALUE klass;
|
||||
|
||||
klass = rb_eval(self, node->nd_recv);
|
||||
if (rb_special_const_p(klass)) {
|
||||
rb_raise(rb_eTypeError, "no virtual class for %s",
|
||||
rb_class2name(CLASS_OF(klass)));
|
||||
result = rb_eval(self, node->nd_recv);
|
||||
if (result == Qtrue) {
|
||||
klass = rb_cTrueClass;
|
||||
}
|
||||
else if (result == Qfalse) {
|
||||
klass = rb_cTrueClass;
|
||||
}
|
||||
else if (result == Qnil) {
|
||||
klass = rb_cNilClass;
|
||||
}
|
||||
else {
|
||||
if (rb_special_const_p(result)) {
|
||||
rb_raise(rb_eTypeError, "no virtual class for %s",
|
||||
rb_class2name(CLASS_OF(klass)));
|
||||
}
|
||||
if (rb_safe_level() >= 4 && !OBJ_TAINTED(result))
|
||||
rb_raise(rb_eSecurityError, "Insecure: can't extend object");
|
||||
klass = rb_singleton_class(result);
|
||||
}
|
||||
if (rb_safe_level() >= 4 && !OBJ_TAINTED(klass))
|
||||
rb_raise(rb_eSecurityError, "Insecure: can't extend object");
|
||||
klass = rb_singleton_class(klass);
|
||||
|
||||
if (ruby_wrapper) {
|
||||
rb_extend_object(klass, ruby_wrapper);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue