From: "jnchito (Junichi Ito) via ruby-core" Date: 2024-12-22T04:04:12+00:00 Subject: [ruby-core:120363] [Ruby master Bug#20977] backtick is used for syntax errors related to 'it' Issue #20977 has been reported by jnchito (Junichi Ito). ---------------------------------------- Bug #20977: backtick is used for syntax errors related to 'it' https://bugs.ruby-lang.org/issues/20977 * Author: jnchito (Junichi Ito) * Status: Open * ruby -v: ruby 3.4.0rc1 (2024-12-12 master 29caae9991) +PRISM [arm64-darwin24] * Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN ---------------------------------------- The following error message uses single quote for "'it'": ``` irb(main):012> [10].each_with_index { p "#{it}:#{_2}" } #=> 10 irb(main):013> :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 '' 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 '
' ``` 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 :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 '' 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 '
' ``` So it should use single quote for consistency. -- https://bugs.ruby-lang.org/ ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/