Project

General

Profile

Bug #10016

Destructuring block arguments with a Hashable last element

Added by brixen (Brian Shirai) almost 5 years ago. Updated almost 5 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
ruby -v:
ruby 2.2.0dev (2014-06-05 trunk 46353) [x86_64-darwin13]
[ruby-core:63593]

Description

The following code:

# destructure_bug.rb
def m
  x = Object.new
  def x.to_hash() {x: 9} end

  yield [1, 2, 3, x]
end

p m { |a, *b, c, **k| [a, b, c, k] }

gives:

$ ruby -v destructure_bug.rb
ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-darwin13.0]
[#<Object:0x007fc5fb212870>, [nil], 1, {:x=>9}]

$ ruby -v destructure_bug.rb
ruby 2.2.0dev (2014-06-05 trunk 46353) [x86_64-darwin13]
[#<Object:0x007f88c206c2a8>, [nil], 1, {:x=>9}]

I would expect: [1, [2], 3, {:x=>9}]

Is this a bug?

Associated revisions

Revision 813ad489
Added by nobu (Nobuyoshi Nakada) almost 5 years ago

vm_insnhelper.c: fix implicit splat keyword argument

  • vm_insnhelper.c (vm_callee_setup_keyword_arg): adjust VM stack pointer to get rid of overwriting splat arguments by arguments for to_hash conversion. [ruby-core:63593] [Bug #10016]

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

Revision 46775
Added by nobu (Nobuyoshi Nakada) almost 5 years ago

vm_insnhelper.c: fix implicit splat keyword argument

  • vm_insnhelper.c (vm_callee_setup_keyword_arg): adjust VM stack pointer to get rid of overwriting splat arguments by arguments for to_hash conversion. [ruby-core:63593] [Bug #10016]

Revision 46775
Added by nobu (Nobuyoshi Nakada) almost 5 years ago

vm_insnhelper.c: fix implicit splat keyword argument

  • vm_insnhelper.c (vm_callee_setup_keyword_arg): adjust VM stack pointer to get rid of overwriting splat arguments by arguments for to_hash conversion. [ruby-core:63593] [Bug #10016]

Revision 46775
Added by nobu (Nobuyoshi Nakada) almost 5 years ago

vm_insnhelper.c: fix implicit splat keyword argument

  • vm_insnhelper.c (vm_callee_setup_keyword_arg): adjust VM stack pointer to get rid of overwriting splat arguments by arguments for to_hash conversion. [ruby-core:63593] [Bug #10016]

Revision 46775
Added by nobu (Nobuyoshi Nakada) almost 5 years ago

vm_insnhelper.c: fix implicit splat keyword argument

  • vm_insnhelper.c (vm_callee_setup_keyword_arg): adjust VM stack pointer to get rid of overwriting splat arguments by arguments for to_hash conversion. [ruby-core:63593] [Bug #10016]

Revision 46775
Added by nobu (Nobuyoshi Nakada) almost 5 years ago

vm_insnhelper.c: fix implicit splat keyword argument

  • vm_insnhelper.c (vm_callee_setup_keyword_arg): adjust VM stack pointer to get rid of overwriting splat arguments by arguments for to_hash conversion. [ruby-core:63593] [Bug #10016]

Revision 46775
Added by nobu (Nobuyoshi Nakada) almost 5 years ago

vm_insnhelper.c: fix implicit splat keyword argument

  • vm_insnhelper.c (vm_callee_setup_keyword_arg): adjust VM stack pointer to get rid of overwriting splat arguments by arguments for to_hash conversion. [ruby-core:63593] [Bug #10016]

Revision 6ff49bf8
Added by nagachika (Tomoyuki Chikanaga) almost 5 years ago

merge revision(s) r46775: [Backport #10016]

    * vm_insnhelper.c (vm_callee_setup_keyword_arg): adjust VM stack
      pointer to get rid of overwriting splat arguments by arguments
      for `to_hash` conversion.  [ruby-core:63593] [Bug #10016]

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

Revision 47138
Added by nagachika (Tomoyuki Chikanaga) almost 5 years ago

merge revision(s) r46775: [Backport #10016]

* vm_insnhelper.c (vm_callee_setup_keyword_arg): adjust VM stack
  pointer to get rid of overwriting splat arguments by arguments
  for `to_hash` conversion.  [ruby-core:63593] [Bug #10016]

History

Updated by nobu (Nobuyoshi Nakada) almost 5 years ago

  • Description updated (diff)
  • Category set to core
  • Target version set to 2.2.0
  • Backport changed from 2.0.0: UNKNOWN, 2.1: UNKNOWN to 2.0.0: REQUIRED, 2.1: REQUIRED

Elements expanded on the VM stack are overwritten by calling to_hash method.

Updated by nobu (Nobuyoshi Nakada) almost 5 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

Applied in changeset r46775.


vm_insnhelper.c: fix implicit splat keyword argument

  • vm_insnhelper.c (vm_callee_setup_keyword_arg): adjust VM stack pointer to get rid of overwriting splat arguments by arguments for to_hash conversion. [ruby-core:63593] [Bug #10016]

Updated by nagachika (Tomoyuki Chikanaga) almost 5 years ago

  • Backport changed from 2.0.0: REQUIRED, 2.1: REQUIRED to 2.0.0: REQUIRED, 2.1: DONE

Backported into ruby_2_1 branch at r47138.

Updated by usa (Usaku NAKAMURA) almost 5 years ago

  • Backport changed from 2.0.0: REQUIRED, 2.1: DONE to 2.0.0: WONTFIX, 2.1: DONE

Also available in: Atom PDF