Actions
Bug #21139
open
Prism and parse.y parses `it = it` differently
ruby -v:
ruby 3.5.0dev (2025-02-14T16:49:52Z master ee181d1bb7) +PRISM [x86_64-linux]
Description
# ruby --parser=parse.y -e "42.tap { it = it; p it }"
nil
# ruby --parser=prism -e "42.tap { it = it; p it }"
42
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.
- Currently,
it
is an ordinary local variable if assigned syntactically. - 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?
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
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
Like0
Like0Like0Like0Like0