From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: poffice@blade.nagaokaut.ac.jp Delivered-To: poffice@blade.nagaokaut.ac.jp Received: from kankan.nagaokaut.ac.jp (kankan.nagaokaut.ac.jp [133.44.2.24]) by blade.nagaokaut.ac.jp (Postfix) with ESMTP id 5B0001A000FD for ; Wed, 24 Feb 2016 12:54:46 +0900 (JST) Received: from voscc.nagaokaut.ac.jp (voscc.nagaokaut.ac.jp [133.44.1.100]) by kankan.nagaokaut.ac.jp (Postfix) with ESMTP id 60008B5D897 for ; Wed, 24 Feb 2016 13:30:01 +0900 (JST) Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by voscc.nagaokaut.ac.jp (Postfix) with ESMTP id BB19818CC7CC for ; Wed, 24 Feb 2016 13:30:01 +0900 (JST) Received: from [221.186.184.76] (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 203B9120458; Wed, 24 Feb 2016 13:30:00 +0900 (JST) X-Original-To: ruby-core@ruby-lang.org Delivered-To: ruby-core@ruby-lang.org Received: from o10.shared.sendgrid.net (o10.shared.sendgrid.net [173.193.132.135]) by neon.ruby-lang.org (Postfix) with ESMTPS id 2FCB812044C for ; Wed, 24 Feb 2016 13:29:55 +0900 (JST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sendgrid.me; h=from:to:references:subject:mime-version:content-type:content-transfer-encoding:list-id; s=smtpapi; bh=dndro9wxsM3M7RhJMYInX6pMR2A=; b=ZbacK89US3fvYtkQYx OWXiCak3j/A/mCO8Ix1DaTIOYzScLCjMxVMVbQfyDGds0S1iJQ9kp3bLzF0QlbBn zd28h/ELEJkeLX77BlgTE43FnMCnPLcIVfqQwQbD5yxlgezhLz+bQ/6lgDmCrkQn M7LGY27mu0/Wypw44pIXpurRA= Received: by filter0870p1mdw1.sendgrid.net with SMTP id filter0870p1mdw1.25974.56CD31BF42 2016-02-24 04:29:51.982214278 +0000 UTC Received: from herokuapp.com (ec2-54-145-60-51.compute-1.amazonaws.com [54.145.60.51]) by ismtpd0001p1iad1.sendgrid.net (SG) with ESMTP id 6Qg67NntTfmMQxeTA0i2mQ for ; Wed, 24 Feb 2016 04:29:51.874 +0000 (UTC) Date: Wed, 24 Feb 2016 04:29:51 +0000 From: pablodherrero@gmail.com To: ruby-core@ruby-lang.org Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 48559 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 12106 X-Redmine-Issue-Author: pabloh X-Redmine-Sender: pabloh X-Mailer: Redmine X-Redmine-Host: bugs.ruby-lang.org X-Redmine-Site: Ruby Issue Tracking System X-Auto-Response-Suppress: All Auto-Submitted: auto-generated X-SG-EID: ync6xU2WACa70kv/Ymy4QrNMhiuLXJG8OTL2vJD1yS7zogxNxCt16WncstXBiYrE/i8FyQorizUcH+ LRaTNco9jZvrUSTek2iINOLPlkX2c2Bh0Yi6MMBlOklngwPCe2XIGppxy1ncnXc8WA6JHMgEHljTBx P3wVTnPeIyX7J0HkQlom9/0Dxg9Ypqy8gGi9X/cirfODIu1Xb13bBFjpLA== X-ML-Name: ruby-core X-Mail-Count: 73957 Subject: [ruby-core:73957] [Ruby trunk Bug#12106] Behavior of double splatting of hashes with non symbol key is different according to splatted hash position X-BeenThere: ruby-core@ruby-lang.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Ruby developers List-Id: Ruby developers List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ruby-core-bounces@ruby-lang.org Sender: "ruby-core" Issue #12106 has been reported by Pablo Herrero. ---------------------------------------- Bug #12106: Behavior of double splatting of hashes with non symbol key is different according to splatted hash position https://bugs.ruby-lang.org/issues/12106 * Author: Pablo Herrero * Status: Open * Priority: Normal * Assignee: * ruby -v: ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-linux] * Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN ---------------------------------------- When doing double splatting with hash with non symbols keys you get different behaviors according to the position of the hash been splatted: ```ruby {a: 3, **{b: 1}, **{'b' => 1}} # Works fine {a: 3, **{1 => 1}, **{b: 1}} # Works fine {3 => 3, **{b: 1}, **{'b' => 1}} # Works fine {**{}, a: 3, **{b: 1}, **{1 => 1}} # Works fine {**{b: 1}, a: 3, **{1 => 1}} # TypeError: wrong argument type Fixnum (expected Symbol) {**{'b' => 1}, **{c: 4}} # TypeError: wrong argument type Fixnum (expected Symbol) {**{c: 4}, **{'b' => 1}} # TypeError: wrong argument type Fixnum (expected Symbol) {**{c: 4}, a: 3, **{'b' => 1}} # TypeError: wrong argument type Fixnum (expected Symbol) ``` Same thing happens when you double splat inside a message send: ```ruby puts(a: 3, **{b: 1}, **{'b' => 1}) # Works fine puts(a: 3, **{1 => 1}, **{b: 1}) # Works fine puts(3 => 3, **{b: 1}, **{'b' => 1}) # Works fine puts(**{}, a: 3, **{b: 1}, **{1 => 1}) # Works fine puts(**{b: 1}, a: 3, **{1 => 1}) # TypeError: wrong argument type Fixnum (expected Symbol) puts(**{'b' => 1}, **{c: 4}) # TypeError: wrong argument type Fixnum (expected Symbol) puts(**{c: 4}, **{'b' => 1}) # TypeError: wrong argument type Fixnum (expected Symbol) puts(**{c: 4}, a: 3, **{'b' => 1}) # TypeError: wrong argument type Fixnum (expected Symbol) ``` What's basically going on is this: you can double splat hashes with no symbol keys all you want, only if the first value of the hash is a regular key (symbol or not) and not a splatted hash, or also a double splatted empty hash. It feels strange that building the same hash in different orders yields so different behaviors. Anyhow, I personally feel it should be a bug if you cannot splat a hash with no symbol keys into another one, whichever are the remaining values of the hash. -- https://bugs.ruby-lang.org/