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 (smtp.nagaokaut.ac.jp [133.44.2.24]) by blade.nagaokaut.ac.jp (Postfix) with ESMTP id C1A511A00696 for ; Wed, 16 Mar 2016 18:05:36 +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 0A43AB5D8D8 for ; Wed, 16 Mar 2016 18:41:49 +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 953FE18CC7B1 for ; Wed, 16 Mar 2016 18:41:49 +0900 (JST) Received: from [221.186.184.76] (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 992D512044D; Wed, 16 Mar 2016 18:41:49 +0900 (JST) X-Original-To: ruby-core@ruby-lang.org Delivered-To: ruby-core@ruby-lang.org Received: from o2.heroku.sendgrid.net (o2.heroku.sendgrid.net [67.228.50.55]) by neon.ruby-lang.org (Postfix) with ESMTPS id 1BF44120439 for ; Wed, 16 Mar 2016 18:41:44 +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=f9eYFWP15cjp5/TOLaOQVWrYgOA=; b=cbG4oeANn+FFLLQX9B cFu54sp6oS24OnJmEOqFDr5z4yDzXoYCnqZapAbamFxqEKuQAknrOpE8lDpU4tGM 2rAKYRYXuWB1Q3eWtG1G0eXShSzsSUbfZgi2UlZ5HCLO7E/zlXWrkoFiS1YekD7n OKSiLZYPb/D1Nqo/GaAD7CW38= Received: by filter0831p1mdw1.sendgrid.net with SMTP id filter0831p1mdw1.6318.56E92A555 2016-03-16 09:41:41.072017484 +0000 UTC Received: from herokuapp.com (ec2-54-144-22-168.compute-1.amazonaws.com [54.144.22.168]) by ismtpd0005p1iad1.sendgrid.net (SG) with ESMTP id 5Jae_AK7S1CvNsyZTp8AEA for ; Wed, 16 Mar 2016 09:41:41.114 +0000 (UTC) Date: Wed, 16 Mar 2016 09:41:40 +0000 From: shyouhei@ruby-lang.org To: ruby-core@ruby-lang.org Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 48981 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 12106 X-Redmine-Issue-Author: pabloh X-Redmine-Issue-Assignee: nobu X-Redmine-Sender: shyouhei 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/Ymy4QrNMhiuLXJG8OTL2vJD1yS4NBx9GhT1nQ8ElvemfxDbV7sGaBkvzwC1NAG iaT4j5KQkXcjB7LIVGRHV+eqCpwBy5lNQ9R3/Aki5edjMsk/DEQGPMYx+YmgCLG6VwwLyyxh12Q/aP /j4G9h7usrPUQThvejHpbjbxkj6uj909/fYV2G8bRHfid/umqMnzNpgbTQ== X-ML-Name: ruby-core X-Mail-Count: 74375 Subject: [ruby-core:74375] [Ruby trunk Bug#12106][Assigned] 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 updated by Shyouhei Urabe. Status changed from Open to Assigned Assignee set to Nobuyoshi Nakada ---------------------------------------- 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#change-57495 * Author: Pablo Herrero * Status: Assigned * Priority: Normal * Assignee: Nobuyoshi Nakada * 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/