diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2017-03-30 17:09:43 +0900 |
|---|---|---|
| committer | GitHub <[email protected]> | 2017-03-30 17:09:43 +0900 |
| commit | 669b18383d3bd9b2d09216c3cab9d3f2ef0a5ea3 (patch) | |
| tree | d9163c5c65574a8a8db360f2cd12417e5e2be23d /src | |
| parent | 898077a2c28def75b7894cea03f20bb8796b9d27 (diff) | |
| parent | 5efe77fede8c3d57f8be57f5e5b26ab77b8d9c9c (diff) | |
| download | mruby-669b18383d3bd9b2d09216c3cab9d3f2ef0a5ea3.tar.gz mruby-669b18383d3bd9b2d09216c3cab9d3f2ef0a5ea3.zip | |
Merge pull request #3570 from keizo042/fix_cv_definition_in_singleton
Modify class variable definition in singleton class; fix #3539
Diffstat (limited to 'src')
| -rw-r--r-- | src/variable.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/variable.c b/src/variable.c index 2e823453f..f5d261dec 100644 --- a/src/variable.c +++ b/src/variable.c @@ -819,12 +819,22 @@ mrb_mod_cv_set(mrb_state *mrb, struct RClass *c, mrb_sym sym, mrb_value v) c = c->super; } - if (!cls->iv) { - cls->iv = iv_new(mrb); + if (cls && cls->tt == MRB_TT_SCLASS) { + mrb_value klass; + klass = mrb_obj_iv_get(mrb, (struct RObject*)cls, + mrb_intern_lit(mrb, "__attached__")); + + c = mrb_class_ptr(klass); + }else{ + c = cls; + } + + if (!c->iv) { + c->iv = iv_new(mrb); } - mrb_write_barrier(mrb, (struct RBasic*)cls); - iv_put(mrb, cls->iv, sym, v); + mrb_write_barrier(mrb, (struct RBasic*)c); + iv_put(mrb, c->iv, sym, v); } MRB_API void |
