Project

General

Profile

Actions

Bug #21139

open

Prism and parse.y parses `it = it` differently

Added by tompng (tomoya ishida) 7 days ago. Updated 7 days ago.

Status:
Assigned
Assignee:
Target version:
-
ruby -v:
ruby 3.5.0dev (2025-02-14T16:49:52Z master ee181d1bb7) +PRISM [x86_64-linux]
[ruby-core:121054]

Description

# ruby --parser=parse.y -e "42.tap { it = it; p it }"
nil
# ruby --parser=prism -e "42.tap { it = it; p it }"
42

Related issues 2 (0 open2 closed)

Related to Ruby master - Bug #21137: Compound assignment operator with "it" parsed differently between parse.y and prismClosedprismActions
Related to Ruby master - Bug #21138: The modifier expression with "it" is parsed differently in parse.y and Prism, which is unexpected in both.ClosedprismActions

Updated by matz (Yukihiro Matsumoto) 7 days ago

Assignment to it should be prohibited in the long run. Temporarily, I vote for Prism behavior.

Matz.

By the way, how can I clear assignee of the issue on Redmine?

Updated by nobu (Nobuyoshi Nakada) 7 days ago

matz (Yukihiro Matsumoto) wrote in #note-1:

Assignment to it should be prohibited in the long run. Temporarily, I vote for Prism behavior.

  1. Currently, it is an ordinary local variable if assigned syntactically.
  2. And a local variable is nil before assigned, even in its RHS, at the runtime.

The behavior in parse.y obeys above principles.

Do you want to change the rule 1, make it always special?

Actions #3

Updated by nobu (Nobuyoshi Nakada) 6 days ago

  • Related to Bug #21137: Compound assignment operator with "it" parsed differently between parse.y and prism added
Actions #4

Updated by nobu (Nobuyoshi Nakada) 6 days ago

  • Related to Bug #21138: The modifier expression with "it" is parsed differently in parse.y and Prism, which is unexpected in both. added
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0