Project

General

Profile

Feature #7854 » symbol_lookup3_warn.patch

phluid61 (Matthew Kerwin), 03/09/2013 05:54 PM

View differences:

string.c
/*
* call-seq:
* Symbol[str] => Symbol or nil
*
* Returns an extant symbol, which is the .to_sym of +str+, or
* nil if no such symbol exists.
*
* Symbol['Object'] #=> :Object
* Symbol['none such'] #=> nil
*/
VALUE
sym_lookup(VALUE cls, VALUE str)
{
st_data_t id;
if (SYMBOL_P(str)) {
rb_warn("Symbol passed to Symbol[]");
return str;
}
if (id = rb_check_id(&str)) {
return ID2SYM(id);
}
return Qnil;
}
/*
* call-seq:
* sym == obj -> true or false
*
* Equality---If <i>sym</i> and <i>obj</i> are exactly the same
......
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, "[]", sym_lookup, 1);
rb_define_method(rb_cSymbol, "==", sym_equal, 1);
rb_define_method(rb_cSymbol, "===", sym_equal, 1);
(4-4/4)