ruby-changes:46352
From: nobu <ko1@a...>
Date: Mon, 24 Apr 2017 15:18:01 +0900 (JST)
Subject: [ruby-changes:46352] nobu:r58466 (trunk): parse.y: args tail at error
nobu 2017-04-24 15:17:55 +0900 (Mon, 24 Apr 2017) New Revision: 58466 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=58466 Log: parse.y: args tail at error * parse.y (new_args_tail_gen): abandon parsing arguments after error. reported by ilsani Martino Sani (ilsani) at https://hackerone.com/reports/221201 Modified files: trunk/parse.y trunk/test/ruby/test_parse.rb Index: test/ruby/test_parse.rb =================================================================== --- test/ruby/test_parse.rb (revision 58465) +++ test/ruby/test_parse.rb (revision 58466) @@ -958,6 +958,13 @@ x = __ENCODING__ https://github.com/ruby/ruby/blob/trunk/test/ruby/test_parse.rb#L958 assert_syntax_error(" 0b\n", /\^/) end + def test_error_def_in_argument + assert_separately([], "#{<<-"begin;"}\n#{<<~"end;"}") + begin; + assert_syntax_error("def f r:def d; def f 0end", /unexpected/) + end; + end + =begin def test_past_scope_variable assert_warning(/past scope/) {catch {|tag| eval("BEGIN{throw tag}; tap {a = 1}; a")}} Index: parse.y =================================================================== --- parse.y (revision 58465) +++ parse.y (revision 58466) @@ -9965,6 +9965,7 @@ new_args_tail_gen(struct parser_params * https://github.com/ruby/ruby/blob/trunk/parse.y#L9965 args = ZALLOC(struct rb_args_info); node = NEW_NODE(NODE_ARGS, 0, 0, args); + if (parser->error_p) return node; args->block_arg = b; args->kw_args = k; -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/