Project

General

Profile

Bug #18250 ยป 0001-Give-params-a-name.patch

tenderlovemaking (Aaron Patterson), 10/13/2021 12:40 AM

View differences:

bootstraptest/test_ractor.rb
1455 1455
  "ok"
1456 1456
}
1457 1457

  
1458
assert_equal "ok", %q{
1459
  def foo(*); ->{ super }; end
1460
  begin
1461
    Ractor.make_shareable(foo)
1462
  rescue Ractor::IsolationError
1463
    "ok"
1464
  end
1465
}
1466

  
1467
assert_equal "ok", %q{
1468
  def foo(...); ->{ super }; end
1469
  begin
1470
    Ractor.make_shareable(foo)
1471
  rescue Ractor::IsolationError
1472
    "ok"
1473
  end
1474
}
1475

  
1458 1476
end # if !ENV['GITHUB_WORKFLOW']
iseq.c
3033 3033
    return val;
3034 3034
}
3035 3035

  
3036
#define idREST '?'
3037

  
3038
static VALUE
3039
param_name(ID name)
3040
{
3041
    if (name == idREST) {
3042
        return Qfalse;
3043
    }
3044
    else {
3045
        return rb_id2str(name);
3046
    }
3047
}
3048

  
3036 3049
VALUE
3037 3050
rb_iseq_parameters(const rb_iseq_t *iseq, int is_proc)
3038 3051
{
......
3045 3058
#define PARAM_ID(i) body->local_table[(i)]
3046 3059
#define PARAM(i, type) (		      \
3047 3060
	PARAM_TYPE(type),		      \
3048
	rb_id2str(PARAM_ID(i)) ?	      \
3061
	param_name(PARAM_ID(i)) ?	      \
3049 3062
	rb_ary_push(a, ID2SYM(PARAM_ID(i))) : \
3050 3063
	a)
3051 3064

  
parse.y
699 699
# define METHOD_NOT '!'
700 700
#endif
701 701

  
702
#define idREST   '?'
702 703
#define idFWD_REST   '*'
703 704
#ifdef RUBY3_KEYWORDS
704 705
#define idFWD_KWREST idPow /* Use simple "**", as tDSTAR is "**arg" */
......
5538 5539
		| restarg_mark
5539 5540
		    {
5540 5541
		    /*%%%*/
5541
			$$ = internal_id(p);
5542
			arg_var(p, $$);
5542
			arg_var(p, idREST);
5543 5543
		    /*% %*/
5544 5544
		    /*% ripper: rest_param!(Qnil) %*/
5545 5545
		    }
test/ruby/test_iseq.rb
95 95
    assert_equal(42, ISeq.load_from_binary(iseq.to_binary).eval)
96 96
  end
97 97

  
98
  def test_super_with_block
99
    iseq = compile(<<~EOF)
100
      def touch(*) # :nodoc:
101
        foo { super }
102
      end
103
      42
104
    EOF
105
    assert_equal(42, ISeq.load_from_binary(iseq.to_binary).eval)
106
  end
107

  
98 108
  def test_lambda_with_ractor_roundtrip
99 109
    iseq = compile(<<~EOF)
100 110
      x = 42