diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2021-06-17 16:35:39 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2021-06-17 16:35:39 +0900 |
| commit | 090356ec3b237e75cd4e6213685675fd092e6816 (patch) | |
| tree | 6d9d11b7162149d27f17f3f00407f2d3baed8592 /src/variable.c | |
| parent | 62754a4739c7ecae014b2abcb45bfacc07b23b99 (diff) | |
| download | mruby-090356ec3b237e75cd4e6213685675fd092e6816.tar.gz mruby-090356ec3b237e75cd4e6213685675fd092e6816.zip | |
variable.c: skip prepended module for constant lookup.
```ruby
module M
FOO = 'm'
end
class A
FOO = 'a'
prepend M
end
class B < A
def foo
p FOO
end
end
B.new.foo # should print `m` not `a`
```
Diffstat (limited to 'src/variable.c')
| -rw-r--r-- | src/variable.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/variable.c b/src/variable.c index 646353bfd..e1200bc3d 100644 --- a/src/variable.c +++ b/src/variable.c @@ -775,7 +775,7 @@ const_get(mrb_state *mrb, struct RClass *base, mrb_sym sym) L_RETRY: while (c) { - if (c->iv) { + if (!MRB_FLAG_TEST(c, MRB_FL_CLASS_IS_PREPENDED) && c->iv) { if (iv_get(mrb, c->iv, sym, &v)) return v; } |
