1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Reset paren_nest at tAREF and tASET [Bug #17431]

This commit is contained in:
Nobuyoshi Nakada 2020-12-24 01:25:22 +09:00
parent fb54574393
commit 4a8ff22f0c
No known key found for this signature in database
GPG key ID: 7CD2805BFA3770C6
2 changed files with 19 additions and 0 deletions

View file

@ -9668,6 +9668,7 @@ parser_yylex(struct parser_params *p)
p->lex.paren_nest++;
if (IS_AFTER_OPERATOR()) {
if ((c = nextc(p)) == ']') {
p->lex.paren_nest--;
SET_LEX_STATE(EXPR_ARG);
if ((c = nextc(p)) == '=') {
return tASET;

View file

@ -619,6 +619,11 @@ WARN
def test_do_block_after_lambda
bug11380 = '[ruby-core:70067] [Bug #11380]'
assert_valid_syntax('p -> { :hello }, a: 1 do end', bug11380)
assert_valid_syntax('->(opt = (foo.[] bar)) {}')
assert_valid_syntax('->(opt = (foo.[]= bar)) {}')
assert_valid_syntax('->(opt = (foo.[] bar)) do end')
assert_valid_syntax('->(opt = (foo.[]= bar)) do end')
end
def test_reserved_method_no_args
@ -998,6 +1003,19 @@ eom
assert_warn('') {eval("(1...)")}
assert_warn('') {eval("(1...\n2)")}
assert_warn('') {eval("{a: 1...\n2}")}
assert_warn(/\.\.\. at EOL/) do
assert_valid_syntax('foo.[]= ...', verbose: true)
end
assert_warn(/\.\.\. at EOL/) do
assert_valid_syntax('foo.[] ...', verbose: true)
end
assert_warn(/\.\.\. at EOL/) do
assert_syntax_error('foo.[]= bar, ...', /unexpected/, verbose: true)
end
assert_warn(/\.\.\. at EOL/) do
assert_syntax_error('foo.[] bar, ...', /unexpected/, verbose: true)
end
end
def test_too_big_nth_ref