mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
class.c (init_copy): need to copy float numbers in some cases
If `MRB_BOXING_WORD` and `MRB_WORDBOXING_NO_FLOAT_TRANCATE` is defined, float numbers are packed in the heap object. We need to copy them explicitly.
This commit is contained in:
@@ -2719,6 +2719,14 @@ init_copy(mrb_state *mrb, mrb_value dest, mrb_value obj)
|
||||
case MRB_TT_ISTRUCT:
|
||||
mrb_istruct_copy(dest, obj);
|
||||
break;
|
||||
#if !defined(MRB_NO_FLOAT) && defined(MRB_WORDBOX_NO_FLOAT_TRUNCATE)
|
||||
case MRB_TT_FLOAT:
|
||||
{
|
||||
struct RFloat *f = (struct RFloat*)mrb_obj_ptr(dest);
|
||||
f->f = mrb_float(obj);
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
#ifdef MRB_USE_BIGINT
|
||||
case MRB_TT_BIGINT:
|
||||
mrb_bint_copy(mrb, dest, obj);
|
||||
|
||||
Reference in New Issue
Block a user