aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-04-24 06:17:55 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-04-24 06:17:55 +0000
commit80f50674781b2e8cbc40287142fb1d06f27e4d76 (patch)
tree42d30e2e7babdd137c5f0176c09ac3c20422cbd8
parent7c23609e6057a5cbe8e9c7b39ba565bd75dd2a09 (diff)
downloadruby-80f50674781b2e8cbc40287142fb1d06f27e4d76.tar.gz
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 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58466 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--parse.y1
-rw-r--r--test/ruby/test_parse.rb7
2 files changed, 8 insertions, 0 deletions
diff --git a/parse.y b/parse.y
index 11cab865a2..86486ac38a 100644
--- a/parse.y
+++ b/parse.y
@@ -9965,6 +9965,7 @@ new_args_tail_gen(struct parser_params *parser, NODE *k, ID kr, ID b)
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;
diff --git a/test/ruby/test_parse.rb b/test/ruby/test_parse.rb
index b4a63e369d..c2ee56ae52 100644
--- a/test/ruby/test_parse.rb
+++ b/test/ruby/test_parse.rb
@@ -958,6 +958,13 @@ x = __ENCODING__
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")}}