Issue #6936 has been updated by naruse (Yui NARUSE).


ko1 (Koichi Sasada) wrote:
> (2012/08/27 22:35), NARUSE, Yui wrote:
>  > (2012/08/27 17:46), KOSAKI Motohiro wrote:
>  >>>> ???????????????????????????????????????????????????????????????? frozen ???????????????????????????????????????????
>  >>>
>  >>> ???Numeric ??? freeze ?????????????????????????????????????????????
>  >>
>  >> ???????????????????????????????????念?????????????????????????????????????????????????????????????????????????????
>  > 
>  > ????????????????????????????統???????????????????????????????????????????????
>  
>  ????????????????影???????????????Float ?????? frozen ????????????????????????
>  ???????

以??????????????????????????

diff --git a/class.c b/class.c
index 1d871fb..1df38e4 100644
--- a/class.c
+++ b/class.c
@@ -1324,6 +1324,10 @@ singleton_class_of(VALUE obj)
            rb_bug("unknown immediate %p", (void *)obj);
        return klass;
     }
+    else {
+       if (BUILTIN_TYPE(obj) == T_FLOAT)
+           rb_raise(rb_eTypeError, "can't define singleton");
+    }
 
     if (FL_TEST(RBASIC(obj)->klass, FL_SINGLETON) &&
        rb_ivar_get(RBASIC(obj)->klass, id_attached) == obj) {
diff --git a/include/ruby/ruby.h b/include/ruby/ruby.h
index a674de8..53de6a8 100644
--- a/include/ruby/ruby.h
+++ b/include/ruby/ruby.h
@@ -1129,7 +1129,7 @@ struct RBignum {
                         (FL_TAINT | FL_UNTRUSTED); \
 } while (0)
 
-#define OBJ_FROZEN(x) (!!FL_TEST((x), FL_FREEZE))
+#define OBJ_FROZEN(x) (!!(FL_ABLE(x)?(RBASIC(x)->flags&(FL_FREEZE)):FLONUM_P(x)))
 #define OBJ_FREEZE(x) FL_SET((x), FL_FREEZE)
 
 #if SIZEOF_INT < SIZEOF_LONG
diff --git a/numeric.c b/numeric.c
index 58ac7ad..6a72fba 100644
--- a/numeric.c
+++ b/numeric.c
@@ -621,6 +621,7 @@ rb_float_new_in_heap(double d)
     OBJSETUP(flt, rb_cFloat, T_FLOAT);
 
     flt->float_value = d;
+    OBJ_FREEZE(flt);
     return (VALUE)flt;
 }

----------------------------------------
Feature #6936: Forbid singleton class and instance variabls for float
https://bugs.ruby-lang.org/issues/6936#change-29181

Author: naruse (Yui NARUSE)
Status: Assigned
Priority: Normal
Assignee: matz (Yukihiro Matsumoto)
Category: core
Target version: 2.0.0


[Feature #6763] ????議?????????????? flonum ??? r36798 ????????????????????????

1. Float ???????????ID ????????????
2. flonum ??? float ??????????????追?????
3. flonum ??? float ????????????????
4. flonum ??? float ???????????士??????????????????????????

??????????????????????????????
???????????1. ????常??????????????????????????????????2. ???????????止????????????????
?????????? 3. ??? 4. ????????????? 1.9.3 ????????????????????????????
32bit ???????? 2.0 ??????64bit??????? flonum ????? float ???????????????????????????????????

???????????????害??????????????????????????????????????????????????極????????????????
Ruby ??????????????????????????????????????????????????????????

????????以??????????????????????????????????????????????
* flonum ????? float ?????????????????????
* float ???????????????????????

???????????????????????????????????????????????????????????????? frozen ???????????????????????????????????????????

話??????????????????????話??? true, false, nil, Fixnum, Symbol ???????????????????
Bignum ??????Time ?????????? immutable ????????????????????????????????????????????


-- 
http://bugs.ruby-lang.org/