Project

General

Profile

Bug #16138 ยป ruby_2_6.patch

Patch for Ruby 2.6 - prajjwal (Prajjwal Singh), 09/04/2019 09:34 AM

View differences:

struct.c
516 516
static VALUE
517 517
rb_struct_s_def(int argc, VALUE *argv, VALUE klass)
518 518
{
519
    VALUE name, rest, keyword_init;
519
    VALUE name, rest, keyword_init = Qfalse;
520 520
    long i;
521 521
    VALUE st;
522 522
    st_table *tbl;
......
532 532
    }
533 533

  
534 534
    if (RB_TYPE_P(argv[argc-1], T_HASH)) {
535
	VALUE kwargs[1];
536 535
	static ID keyword_ids[1];
537 536

  
538 537
	if (!keyword_ids[0]) {
539 538
	    keyword_ids[0] = rb_intern("keyword_init");
540 539
	}
541
	rb_get_kwargs(argv[argc-1], keyword_ids, 0, 1, kwargs);
540

  
541
	rb_get_kwargs(argv[argc-1], keyword_ids, 0, 1, &keyword_init);
542
	if (keyword_init == Qundef) {
543
		keyword_init = Qfalse;
544
	}
545

  
542 546
	--argc;
543
	keyword_init = kwargs[0];
544
    }
545
    else {
546
	keyword_init = Qfalse;
547 547
    }
548 548

  
549 549
    rest = rb_ident_hash_new();
test/ruby/test_struct.rb
92 92
    assert_equal([:utime, :stime, :cutime, :cstime], Process.times.members)
93 93
  end
94 94

  
95
  def test_struct_new_with_empty_hash
96
    assert_equal({:a=>1}, Struct.new(:a, {}).new({:a=>1}).a)
97
  end
98

  
95 99
  def test_struct_new_with_keyword_init
96 100
    @Struct.new("KeywordInitTrue", :a, :b, keyword_init: true)
97 101
    @Struct.new("KeywordInitFalse", :a, :b, keyword_init: false)
98
-