From: ibylich@... Date: 2020-12-23T15:57:15+00:00 Subject: [ruby-core:101658] [Ruby master Bug#17431] paren_nest is not reset in parse.y after "foo.[]= value" Issue #17431 has been updated by ibylich (Ilya Bylich). The following patch seems to be the fix: ``` diff --git a/parse.y b/parse.y index c65a469a..a4f6bcc8 100644 --- a/parse.y +++ b/parse.y @@ -9668,6 +9669,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; ``` ---------------------------------------- Bug #17431: paren_nest is not reset in parse.y after "foo.[]= value" https://bugs.ruby-lang.org/issues/17431#change-89447 * Author: ibylich (Ilya Bylich) * Status: Assigned * Priority: Normal * Assignee: nobu (Nobuyoshi Nakada) * ruby -v: ruby 3.0.0dev (2020-12-23T14:40:04Z master 94015200b6) [x86_64-darwin19] * Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN ---------------------------------------- `p->lex.paren_nest` is equal to 1 after the following code: ```ruby self.[]= foo ``` `paren_nest` is used to differentiate `...` for ranges/forwarded arguments, and so `./miniruby -we 'foo.[]= bar, ...'` gives no `... at EOL, should be parenthesized?` warning (`./miniruby -we 'foo.x= bar, ...'` does). Also it's used to differentiate `kDO` vs `kDO_LAMBDA`, so I believe there are code samples with lambdas and `.[]=` calls that can't be handled by Ruby but are technically valid. -- https://bugs.ruby-lang.org/ Unsubscribe: