Permalink
Browse files

resolve conflict; ref #3281

  • Loading branch information...
matz committed Nov 25, 2016
2 parents 7f05ba8 + b60d6c4 commit 79e3980a7fea28a729393f4fb43415948255027e
Showing with 14 additions and 18 deletions.
  1. +8 −18 mrbgems/mruby-struct/src/struct.c
  2. +6 −0 mrbgems/mruby-struct/test/struct.rb
@@ -273,25 +273,15 @@ mrb_struct_s_def(mrb_state *mrb, mrb_value klass)
}
else {
if (argc > 0) name = argv[0];
if (argc > 1) rest = argv[1];
if (mrb_array_p(rest)) {
if (!mrb_nil_p(name) && mrb_symbol_p(name)) {
/* 1stArgument:symbol -> name=nil rest=argv[0]-[n] */
mrb_ary_unshift(mrb, rest, name);
name = mrb_nil_value();
}
}
else {
pargv = &argv[1];
argcnt = argc-1;
if (!mrb_nil_p(name) && mrb_symbol_p(name)) {
/* 1stArgument:symbol -> name=nil rest=argv[0]-[n] */
name = mrb_nil_value();
pargv = &argv[0];
argcnt++;
}
rest = mrb_ary_new_from_values(mrb, argcnt, pargv);
pargv = &argv[1];
argcnt = argc-1;
if (!mrb_nil_p(name) && mrb_symbol_p(name)) {
/* 1stArgument:symbol -> name=nil rest=argv[0]-[n] */
name = mrb_nil_value();
pargv = &argv[0];
argcnt++;
}
rest = mrb_ary_new_from_values(mrb, argcnt, pargv);
for (i=0; i<RARRAY_LEN(rest); i++) {
id = mrb_obj_to_sym(mrb, RARRAY_PTR(rest)[i]);
mrb_ary_set(mrb, rest, i, mrb_symbol_value(id));
@@ -179,3 +179,9 @@
Struct.remove_const :Test
end
end
assert("Struct.new does not allow array") do
assert_raise(TypeError) do
Struct.new("Test", [:a])
end
end

0 comments on commit 79e3980

Please sign in to comment.