diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2016-07-25 14:19:10 +0900 |
|---|---|---|
| committer | GitHub <[email protected]> | 2016-07-25 14:19:10 +0900 |
| commit | a66a1e92e79c25b14beb8a950ae96a7189b9a38d (patch) | |
| tree | c86aafc625aac1e4b8580f3b60e4b845cb7f9d28 | |
| parent | 34ac707ea34880e168dc2428d477a33ca7ffec7d (diff) | |
| parent | bf21063a7245f5d8ae0773cf88422bece9d0e784 (diff) | |
| download | mruby-a66a1e92e79c25b14beb8a950ae96a7189b9a38d.tar.gz mruby-a66a1e92e79c25b14beb8a950ae96a7189b9a38d.zip | |
Merge pull request #3179 from ksss/struct
Should not define to `Struct` class
| -rw-r--r-- | mrbgems/mruby-struct/src/struct.c | 2 | ||||
| -rw-r--r-- | mrbgems/mruby-struct/test/struct.rb | 3 |
2 files changed, 4 insertions, 1 deletions
diff --git a/mrbgems/mruby-struct/src/struct.c b/mrbgems/mruby-struct/src/struct.c index 51256c6af..1a06e0c12 100644 --- a/mrbgems/mruby-struct/src/struct.c +++ b/mrbgems/mruby-struct/src/struct.c @@ -299,7 +299,7 @@ mrb_struct_s_def(mrb_state *mrb, mrb_value klass) } st = make_struct(mrb, name, rest, struct_class(mrb)); if (!mrb_nil_p(b)) { - mrb_yield_with_class(mrb, b, 1, &st, st, mrb_class_ptr(klass)); + mrb_yield_with_class(mrb, b, 1, &st, st, mrb_class_ptr(st)); } return st; diff --git a/mrbgems/mruby-struct/test/struct.rb b/mrbgems/mruby-struct/test/struct.rb index 63a02817e..02ecf69e4 100644 --- a/mrbgems/mruby-struct/test/struct.rb +++ b/mrbgems/mruby-struct/test/struct.rb @@ -23,6 +23,9 @@ assert('Struct#==', '15.2.18.4.1') do cc1 = c.new(1,2) cc2 = c.new(1,2) assert_true cc1 == cc2 + + Struct.new(:m1, :m2) { def foo; end } + assert_raise(NoMethodError) { Struct.new(:m1).new.foo } end assert('Struct#[]', '15.2.18.4.2') do |
