Project

General

Profile

Actions

Bug #21138

closed

The modifier expression with "it" is parsed differently in parse.y and Prism, which is unexpected in both.

Added by kinoppyd (Yasuhiro Kinoshita) 9 days ago. Updated 8 days ago.

Status:
Closed
Assignee:
Target version:
-
ruby -v:
ruby 3.4.1 (2024-12-25 revision 48d4efcb85) [arm64-darwin21]
[ruby-dev:<unknown>]

Description

Actual

parse.y

In parse.y, the block parameter "it" behaves as if it is not assigned.

# parse.y
loop.rb:1:in 'block in <main>': undefined method '<' for nil (NoMethodError)

1.then { it *= 10 while it < 1000 }
                           ^
	from <internal:kernel>:126:in 'Kernel#then'
	from loop.rb:1:in '<main>'

prism

In Prism, I may not understand what's happening due to my limited knowledge, but it results in a syntax error."

unexpected integer; expected an expression after the operator
unexpected integer, expecting end-of-input

> 1  1.then { it *= 10 while it < 1000 }

loop.rb:1: syntax errors found (SyntaxError)
> 1 | 1.then { it *= 10 while it < 1000 }
    |             ^~ unexpected integer; expected an expression after the operator
    |                ^~ unexpected integer, expecting end-of-input

Expected

'It' should be reassigned until it is greater than 1000.


Related issues 2 (1 open1 closed)

Related to Ruby master - Bug #21139: Prism and parse.y parses `it = it` differentlyAssignedprismActions
Is duplicate of Ruby master - Bug #21137: Compound assignment operator with "it" parsed differently between parse.y and prismClosedprismActions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0