Project

General

Profile

Actions

Bug #21153

closed

::Foo ||= p 1 should parse

Added by qnighy (Masaki Hara) about 1 month ago. Updated 10 days ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 3.5.0dev (2025-02-22T15:11:40Z master fd882fb681) +PRISM [x86_64-linux]
[ruby-core:121141]

Description

There is an inconsistency between how Foo and ::Foo are handled:

% ./miniruby --parser=parse.y -e "Foo ||= p 1"
1
% ./miniruby --parser=parse.y -e "::Foo ||= p 1"
-e:1: syntax error, unexpected integer literal, expecting 'do' or '{' or '('
::Foo ||= p 1
./miniruby: compile error (SyntaxError)

Note that Object::Foo also parses.

Prism successfully parses both, which is what I expect.

% ./miniruby --parser=prism -e "Foo ||= p 1"
1
% ./miniruby --parser=prism -e "::Foo ||= p 1"
1

To fix this, you should probably handle all tOP_ASGNs in the op_asgn rule.

Actions #1

Updated by nobu (Nobuyoshi Nakada) 30 days ago

  • Status changed from Open to Closed

Applied in changeset git|21ac0a3a640a2a86e8716675f82221f178e29088.


[Bug #21153] Add missing op-assign to top const in command_asgn

It was defined in arg only; moved that pattern to op_asgn rule to
share it with command_asgn.

Actions #2

Updated by nobu (Nobuyoshi Nakada) 29 days ago

  • Backport changed from 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN to 3.1: REQUIRED, 3.2: REQUIRED, 3.3: REQUIRED, 3.4: REQUIRED
Actions #4

Updated by ufuk (Ufuk Kayserilioglu) 23 days ago

  • Backport changed from 3.1: REQUIRED, 3.2: REQUIRED, 3.3: REQUIRED, 3.4: REQUIRED to 3.1: REQUIRED, 3.2: REQUIRED, 3.3: REQUIRED, 3.4: DONE
Actions #5

Updated by k0kubun (Takashi Kokubun) 23 days ago

  • Backport changed from 3.1: REQUIRED, 3.2: REQUIRED, 3.3: REQUIRED, 3.4: DONE to 3.1: REQUIRED, 3.2: REQUIRED, 3.3: REQUIRED, 3.4: REQUIRED

Updated by k0kubun (Takashi Kokubun) 23 days ago

  • Backport changed from 3.1: REQUIRED, 3.2: REQUIRED, 3.3: REQUIRED, 3.4: REQUIRED to 3.1: REQUIRED, 3.2: REQUIRED, 3.3: REQUIRED, 3.4: DONE
Actions #7

Updated by nagachika (Tomoyuki Chikanaga) 10 days ago

  • Backport changed from 3.1: REQUIRED, 3.2: REQUIRED, 3.3: REQUIRED, 3.4: DONE to 3.1: REQUIRED, 3.2: REQUIRED, 3.3: WONTFIX, 3.4: DONE
Actions

Also available in: Atom PDF

Like0
Like0Like0Like1Like0Like0Like0Like0