Project

General

Profile

Actions

Bug #20062

closed

Numbered parameters are broken in Ruby 3.3-dev

Added by osyo (manga osyo) about 1 year ago. Updated 5 months ago.

Status:
Closed
Target version:
ruby -v:
ruby 3.3.0dev (2023-12-13T13:16:11Z master f390c51b15) [x86_64-linux]
[ruby-core:115728]

Description

Define Numbered parameters and a method in one block and then reference Numbered parameters in another block, you will get a SyntaxError in Ruby 3.3.
This is not a problem in Ruby 3.2.

'a'.tap do
  p _1

  def f1; end
end

'a'.tap do
  p _1
end

__END__
output:
Ruby 3.2.2 =>
"a"
"a"

Ruby 3.3.0dev(2023-12-13T13:16:11Z master f390c51b15) =>
/path/to/test.rb:
/path/to/test.rb:8: numbered parameter is already used in (SyntaxError)
/path/to/test.rb:2: outer block here

I noticed this while checking the operation of https://bugs.ruby-lang.org/issues/18966.
I haven't checked, but https://bugs.ruby-lang.org/issues/19619 may be related.


Related issues 1 (1 open0 closed)

Is duplicate of Ruby master - Bug #18966: Strange behavior when numbered parameters and method definition are both used in a blockOpenActions

Updated by k0kubun (Takashi Kokubun) about 1 year ago

  • Assignee set to nobu (Nobuyoshi Nakada)

I haven't checked, but https://bugs.ruby-lang.org/issues/19619 may be related.

$ ./miniruby -v /tmp/test.rb
ruby 3.3.0dev (2023-05-02T09:27:10Z master 31774bd565) [x86_64-linux]
"a"
"a"
$ ./miniruby -v /tmp/test.rb
ruby 3.3.0dev (2023-05-02T08:39:18Z master b15e88e0fc) [x86_64-linux]
/tmp/test.rb: /tmp/a.rb:8: numbered parameter is already used in (SyntaxError)
/tmp/test.rb:2: outer block here

It indeed seems to have been broken since https://github.com/ruby/ruby/pull/7779.

Actions #2

Updated by k0kubun (Takashi Kokubun) about 1 year ago

  • Backport changed from 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN to 3.0: DONTNEED, 3.1: DONTNEED, 3.2: DONTNEED
Actions #3

Updated by k0kubun (Takashi Kokubun) about 1 year ago

  • Target version set to 3.3
Actions #5

Updated by nobu (Nobuyoshi Nakada) about 1 year ago

  • Backport changed from 3.0: DONTNEED, 3.1: DONTNEED, 3.2: DONTNEED to 3.0: REQUIRED, 3.1: REQUIRED, 3.2: REQUIRED
Actions #6

Updated by nobu (Nobuyoshi Nakada) about 1 year ago

  • Is duplicate of Bug #18966: Strange behavior when numbered parameters and method definition are both used in a block added
Actions #7

Updated by nobu (Nobuyoshi Nakada) about 1 year ago

  • Status changed from Open to Closed

Applied in changeset git|92b10f5be7453aceb5863e46ac775a4ddbf83b97.


[Bug #20062] Fixed numbered parameter syntax error

At the method definition, the local scope that saves the context of
the numbered parameters needs to be pushed before saving.

Updated by nagachika (Tomoyuki Chikanaga) 5 months ago

  • Backport changed from 3.0: REQUIRED, 3.1: REQUIRED, 3.2: REQUIRED to 3.1: DONTNEED, 3.2: DONTNEED

I believe this issue is not the case on ruby_3_2. The test case added was passed with current ruby_3_2 branch.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like1Like0