Actions
Bug #20977
openbacktick is used for syntax errors related to 'it'
Status:
Open
Assignee:
-
Target version:
-
ruby -v:
ruby 3.4.0rc1 (2024-12-12 master 29caae9991) +PRISM [arm64-darwin24]
Description
The following error message uses single quote for "'it'":
irb(main):012> [10].each_with_index { p "#{it}:#{_2}" } #=> 10
irb(main):013>
<internal:kernel>:168:in 'Kernel#loop': (irb):12: syntax error found (SyntaxError)
> 12 | ... _2}" } #=> 10
| ^~ numbered parameters are not allowed when 'it' is already used
13 |
14 |
from /Users/jnito/.rbenv/versions/3.4.0-rc1/lib/ruby/gems/3.4.0+1/gems/irb-1.14.1/exe/irb:9:in '<top (required)>'
from /Users/jnito/.rbenv/versions/3.4.0-rc1/bin/irb:25:in 'Kernel#load'
from /Users/jnito/.rbenv/versions/3.4.0-rc1/bin/irb:25:in '<main>'
However, the error below uses backtick:
irb(main):019* [1, 2, 3].map.with_index(10) do |n, i|
irb(main):020* it * i
irb(main):021> end
<internal:kernel>:168:in 'Kernel#loop': (irb):20: syntax error found (SyntaxError)
19 | [1, 2, 3].map.with_index(10) do |n, i|
> 20 | it * i
| ^~ `it` is not allowed when an ordinary parameter is defined
21 | end
22 |
from /Users/jnito/.rbenv/versions/3.4.0-rc1/lib/ruby/gems/3.4.0+1/gems/irb-1.14.1/exe/irb:9:in '<top (required)>'
from /Users/jnito/.rbenv/versions/3.4.0-rc1/bin/irb:25:in 'Kernel#load'
from /Users/jnito/.rbenv/versions/3.4.0-rc1/bin/irb:25:in '<main>'
So it should use single quote for consistency.
Actions
Like0
Like0