diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2012-12-22 07:39:55 -0800 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2012-12-22 07:39:55 -0800 |
| commit | c9ba3a16d41c1d46d43b8959ffb12ee782d4a79c (patch) | |
| tree | bdc103e8a9932ae538ceed4893c9625bfc085ffa | |
| parent | a30c7fa73082d1e17bdd3adf87afd40e09640ef8 (diff) | |
| parent | eeb77796030e657d693c3b745e88a5db89cd1def (diff) | |
| download | mruby-c9ba3a16d41c1d46d43b8959ffb12ee782d4a79c.tar.gz mruby-c9ba3a16d41c1d46d43b8959ffb12ee782d4a79c.zip | |
Merge pull request #666 from skandhas/pr-add-nameerror-for-mrb_mod_cv_get
mruby should be throw a NameError, if class variable is not exist.
| -rw-r--r-- | src/variable.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/variable.c b/src/variable.c index 7743c6309..71187af5f 100644 --- a/src/variable.c +++ b/src/variable.c @@ -676,6 +676,8 @@ mrb_mod_class_variables(mrb_state *mrb, mrb_value mod) mrb_value mrb_mod_cv_get(mrb_state *mrb, struct RClass * c, mrb_sym sym) { + struct RClass * cls = c; + while (c) { if (c->iv) { iv_tbl *t = c->iv; @@ -686,6 +688,9 @@ mrb_mod_cv_get(mrb_state *mrb, struct RClass * c, mrb_sym sym) } c = c->super; } + mrb_raisef(mrb, E_NAME_ERROR, "uninitialized class variable %s in %s", + mrb_sym2name(mrb, sym), mrb_class_name(mrb, cls)); + /* not reached */ return mrb_nil_value(); } |
