summaryrefslogtreecommitdiffhomepage
path: root/mrbgems/mruby-struct
diff options
context:
space:
mode:
Diffstat (limited to 'mrbgems/mruby-struct')
-rw-r--r--mrbgems/mruby-struct/src/struct.c2
-rw-r--r--mrbgems/mruby-struct/test/struct.rb3
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