Project

General

Profile

Bug #12568

wrong ArgumentError if an array is given for instance_exec with optional argument

Added by naruse (Yui NARUSE) about 3 years ago. Updated about 3 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
ruby -v:
ruby 2.4.0dev (2016-07-08 trunk 55607) [x86_64-darwin15]
[ruby-core:76300]

Description

From Ruby 2.2 to trunk, it wrongly raise ArgumentError as follows:

Sample code:

instance_exec([1,2,3]){|a| p a}
instance_exec([1,2,3]){|a=[]| p a}
instance_exec([1,2,3], &->(a){ p a })
->(a=[]){ p a }.to_proc.call([1,2,3])
instance_exec([1,2,3], &->(a=[]){ p a })

Expected result:

[1, 2, 3]
[1, 2, 3]
[1, 2, 3]
[1, 2, 3]
[1, 2, 3]

Actual result:

[1, 2, 3]
[1, 2, 3]
[1, 2, 3]
[1, 2, 3]
test.rb:7:in `block in <main>': wrong number of arguments (given 3, expected 0..1) (ArgumentError)
    from test.rb:7:in `instance_exec'
    from test.rb:7:in `<main>'

This issue affect https://github.com/rails/rails/pull/25699


Related issues

Is duplicate of Ruby master - Bug #10687: ArgumentError in certain cases of instance_exec (new bug in 2.2)ClosedActions

Associated revisions

Revision c016898e
Added by naruse (Yui NARUSE) about 3 years ago

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55609 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 55609
Added by naruse (Yui NARUSE) about 3 years ago

Revision 55609
Added by naruse (Yui NARUSE) about 3 years ago

Revision 55609
Added by naruse (Yui NARUSE) about 3 years ago

Revision 55609
Added by naruse (Yui NARUSE) about 3 years ago

Revision af4907c5
Added by usa (Usaku NAKAMURA) about 3 years ago

merge revision(s) 55609: [Backport #12568]

    * vm_args.c (setup_parameters_complex): don't raise ArgumentError
      if an array is given for instance_exec with optional argument.
      [ruby-core:76300] [Bug #12568]
      https://github.com/rails/rails/pull/25699

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@55875 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 55875
Added by usa (Usaku NAKAMURA) about 3 years ago

merge revision(s) 55609: [Backport #12568]

* vm_args.c (setup_parameters_complex): don't raise ArgumentError
  if an array is given for instance_exec with optional argument.
  [ruby-core:76300] [Bug #12568]
  https://github.com/rails/rails/pull/25699

Revision 2c07970d
Added by nagachika (Tomoyuki Chikanaga) about 3 years ago

merge revision(s) 55609: [Backport #12568]

    * vm_args.c (setup_parameters_complex): don't raise ArgumentError
      if an array is given for instance_exec with optional argument.
      [ruby-core:76300] [Bug #12568]
      https://github.com/rails/rails/pull/25699

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_3@55956 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 55956
Added by nagachika (Tomoyuki Chikanaga) about 3 years ago

merge revision(s) 55609: [Backport #12568]

* vm_args.c (setup_parameters_complex): don't raise ArgumentError
  if an array is given for instance_exec with optional argument.
  [ruby-core:76300] [Bug #12568]
  https://github.com/rails/rails/pull/25699

History

Updated by naruse (Yui NARUSE) about 3 years ago

  • Description updated (diff)
#2

Updated by naruse (Yui NARUSE) about 3 years ago

  • Status changed from Open to Closed

Applied in changeset r55609.


Updated by usa (Usaku NAKAMURA) about 3 years ago

  • Backport changed from 2.1: DONTNEED, 2.2: REQUIRED, 2.3: REQUIRED to 2.1: DONTNEED, 2.2: DONE, 2.3: REQUIRED

ruby_2_2 r55875 merged revision(s) 55609.

Updated by nagachika (Tomoyuki Chikanaga) about 3 years ago

  • Backport changed from 2.1: DONTNEED, 2.2: DONE, 2.3: REQUIRED to 2.1: DONTNEED, 2.2: DONE, 2.3: DONE

ruby_2_3 r55956 merged revision(s) 55609.

#5

Updated by nobu (Nobuyoshi Nakada) over 2 years ago

  • Is duplicate of Bug #10687: ArgumentError in certain cases of instance_exec (new bug in 2.2) added

Also available in: Atom PDF