Actions
Bug #21138
closed
The modifier expression with "it" is parsed differently in parse.y and Prism, which is unexpected in both.
ruby -v:
ruby 3.4.1 (2024-12-25 revision 48d4efcb85) [arm64-darwin21]
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.
Actions
Like0
Like0Like0Like0Like0Like0