diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-04-24 06:17:55 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-04-24 06:17:55 +0000 |
commit | b2abac2e8b475e0e19a398e79b7ff2b6170e1d3d (patch) | |
tree | 42d30e2e7babdd137c5f0176c09ac3c20422cbd8 | |
parent | 978b1f6ecca934687a9be242655c621241ea7d9c (diff) | |
download | ruby-b2abac2e8b475e0e19a398e79b7ff2b6170e1d3d.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.y | 1 | ||||
-rw-r--r-- | test/ruby/test_parse.rb | 7 |
2 files changed, 8 insertions, 0 deletions
@@ -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")}} |