Bug #21139
open
Prism and parse.y parses `it = it` differently
Description
# ruby --parser=parse.y -e "42.tap { it = it; p it }"
nil
# ruby --parser=prism -e "42.tap { it = it; p it }"
42
Files
Updated by matz (Yukihiro Matsumoto) about 1 month 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) about 1 month 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) about 1 month ago
- Related to Bug #21137: Compound assignment operator with "it" parsed differently between parse.y and prism added
Updated by nobu (Nobuyoshi Nakada) about 1 month ago
- Related to Bug #21138: The modifier expression with "it" is parsed differently in parse.y and Prism, which is unexpected in both. added
Updated by alanwu (Alan Wu) 21 days ago
- File clipboard-202503081702-idzz2.png clipboard-202503081702-idzz2.png added
- Status changed from Assigned to Open
- Assignee deleted (
prism)
matz (Yukihiro Matsumoto) wrote in #note-1:
By the way, how can I clear assignee of the issue on Redmine?
The null option in the menu is the very first one and is rendered with a tiny height to make it hard to mouse over. It's easier to pick it with arrow keys.
Maybe the UX could be improved by tweaking some settings? CC @hsbt (Hiroshi SHIBATA)
Updated by matz (Yukihiro Matsumoto) 16 days ago
I said I prefer Prism behavior to parse.y
. But It was due to my misunderstanding. it = it
should initialize the local variable named it
and the value should be nil
, just like other x = x
assignment in Ruby.
In the future, all assignment to it
could be prohibited, maybe.
Matz.
Updated by kddnewton (Kevin Newton) 16 days ago
- Assignee set to prism
Updated by hsbt (Hiroshi SHIBATA) 3 days ago
- Status changed from Open to Assigned