diff options
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | string.c | 4 | ||||
-rw-r--r-- | struct.c | 11 |
3 files changed, 11 insertions, 10 deletions
@@ -1,3 +1,9 @@ +Sat Sep 2 23:59:58 2006 Yukihiro Matsumoto <[email protected]> + + * string.c (Init_String): undef Symbol#new. + + * struct.c (rb_struct_s_def): wrong symbol detection. + Sat Sep 2 23:59:37 2006 Yukihiro Matsumoto <[email protected]> * string.c (str_to_id): a bug caused by premature optimization. @@ -4407,7 +4407,6 @@ rb_str_setter(VALUE val, ID id, VALUE *var) /* * call-seq: - * Symbol.new(str) => new_sym * Symbol.intern(str) => new_sym * * Returns a new symbol corresponding to <i>str</i>. @@ -4699,9 +4698,10 @@ Init_String(void) rb_define_variable("$-F", &rb_fs); rb_cSymbol = rb_define_class("Symbol", rb_cString); + rb_undef_alloc_func(rb_cSymbol); + rb_undef_method(CLASS_OF(rb_cSymbol), "new"); rb_define_singleton_method(rb_cSymbol, "all_symbols", rb_sym_all_symbols, 0); /* in parse.y */ rb_define_singleton_method(rb_cSymbol, "intern", rb_sym_s_intern, 1); - rb_define_singleton_method(rb_cSymbol, "new", rb_sym_s_intern, 1); rb_define_method(rb_cSymbol, "to_i", sym_to_i, 0); rb_define_method(rb_cSymbol, "inspect", sym_inspect, 0); @@ -282,14 +282,9 @@ rb_struct_s_def(int argc, VALUE *argv, VALUE klass) id = rb_to_id(RARRAY_PTR(rest)[i]); RARRAY_PTR(rest)[i] = ID2SYM(id); } - if (!NIL_P(name)) { - VALUE tmp = rb_check_string_type(name); - - if (NIL_P(tmp)) { - id = rb_to_id(name); - rb_ary_unshift(rest, ID2SYM(id)); - name = Qnil; - } + if (!NIL_P(name) && SYMBOL_P(name)) { + rb_ary_unshift(rest, name); + name = Qnil; } st = make_struct(name, rest, klass); if (rb_block_given_p()) { |