Actions
Bug #12568
closedwrong ArgumentError if an array is given for instance_exec with optional argument
Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.4.0dev (2016-07-08 trunk 55607) [x86_64-darwin15]
Backport:
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
Updated by naruse (Yui NARUSE) over 7 years ago
- Description updated (diff)
Updated by naruse (Yui NARUSE) over 7 years ago
- Status changed from Open to Closed
Applied in changeset r55609.
- 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
Updated by usa (Usaku NAKAMURA) over 7 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) over 7 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.
Updated by nobu (Nobuyoshi Nakada) about 7 years ago
- Is duplicate of Bug #10687: ArgumentError in certain cases of instance_exec (new bug in 2.2) added
Actions
Like0
Like0Like0Like0Like0Like0