Project

General

Profile

Bug #14062 ยป top-level-return-warn-argument.patch

jeremyevans0 (Jeremy Evans), 07/26/2019 10:15 PM

View differences:

compile.c
6372 6372
	switch (t) {
6373 6373
	  case ISEQ_TYPE_TOP:
6374 6374
	  case ISEQ_TYPE_MAIN:
6375
            if (retval) {
6376
                rb_warn("return at top-level with argument");
6377
            }
6375 6378
	    if (is == iseq) {
6376 6379
		/* plain top-level, leave directly */
6377 6380
		type = ISEQ_TYPE_METHOD;
test/ruby/test_syntax.rb
1195 1195
    end
1196 1196
  end
1197 1197

  
1198
  def test_return_toplevel_with_argument
1199
    assert_warn(/return at top-level with argument/) {eval("return 1")}
1200
  end
1201

  
1198 1202
  def test_syntax_error_in_rescue
1199 1203
    bug12613 = '[ruby-core:76531] [Bug #12613]'
1200 1204
    assert_syntax_error("#{<<-"begin;"}\n#{<<-"end;"}", /Invalid retry/, bug12613)
1201
-