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 F2AEC19802DC for ; Mon, 10 Aug 2015 20:53:38 +0900 (JST) Received: from funfun.nagaokaut.ac.jp (smtp.nagaokaut.ac.jp [133.44.2.201]) by kankan.nagaokaut.ac.jp (Postfix) with ESMTP id B46EFB5D948 for ; Mon, 10 Aug 2015 21:27:49 +0900 (JST) Received: from funfun.nagaokaut.ac.jp (localhost.nagaokaut.ac.jp [127.0.0.1]) by funfun.nagaokaut.ac.jp (Postfix) with ESMTP id 44A6497A838 for ; Mon, 10 Aug 2015 21:27:52 +0900 (JST) X-Virus-Scanned: amavisd-new at nagaokaut.ac.jp Authentication-Results: funfun.nagaokaut.ac.jp (amavisd-new); dkim=fail (1024-bit key) reason="fail (message has been altered)" header.d=sendgrid.me Received: from funfun.nagaokaut.ac.jp ([127.0.0.1]) by funfun.nagaokaut.ac.jp (funfun.nagaokaut.ac.jp [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id y8QHhb9USOSG for ; Mon, 10 Aug 2015 21:27:52 +0900 (JST) Received: from voscc.nagaokaut.ac.jp (voscc.nagaokaut.ac.jp [133.44.1.100]) by funfun.nagaokaut.ac.jp (Postfix) with ESMTP id 000B997A82B for ; Mon, 10 Aug 2015 21:27:51 +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 39C99952439 for ; Mon, 10 Aug 2015 21:27:48 +0900 (JST) Received: from [221.186.184.76] (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id E1068120475; Mon, 10 Aug 2015 21:27:47 +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 4F041120461 for ; Mon, 10 Aug 2015 21:27: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=3yL2y1lYOUXcVbt061tcGo7NtO0=; b=tyzKeeetW5jNmSlLyJ xGw6VTgbD1TjUQIZTr3q0MEaYEzomOSWZdFrbsnTB+gfv83FRloi7aCX3Tefebp7 LN5XrW2KMSDEkIZIcN98wQXHAjNKC+ZCeYcjFrlmOK3EaEemJ4ogMt1FcChPUiwk fJZGuzwMjdaGBLYAeuQ4qeCNQ= Received: by filter0532p1mdw1.sendgrid.net with SMTP id filter0532p1mdw1.4486.55C898BAF 2015-08-10 12:27:38.335076102 +0000 UTC Received: from herokuapp.com (ec2-54-227-125-42.compute-1.amazonaws.com [54.227.125.42]) by ismtpd0004p1iad1.sendgrid.net (SG) with ESMTP id z_ZdOEtpSjm_euU2hf2afg for ; Mon, 10 Aug 2015 12:27:38 +0000 (UTC) Date: Mon, 10 Aug 2015 12:27:38 +0000 From: i@teamon.eu To: ruby-core@ruby-lang.org Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Redmine-MailingListIntegration-Message-Ids: 44910 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 10856 X-Redmine-Issue-Author: seantheprogrammer X-Redmine-Sender: teamon 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/Ymy4QrNMhiuLXJG8OTL2vJD1yS6TPAXOH85LXPssLn9UfkDD6C+/RsydiiJlyi PNqD4e1VnBg/3DHIVEG6J5Lgb8uUwAr5Uw+k39u3yf64K0TOlruE1zxmqk2KmmVRQcz3JMe5dXNUyS OTDDUnm/tTCRoWo= X-ML-Name: ruby-core X-Mail-Count: 70299 Subject: [ruby-core:70299] [Ruby trunk - Bug #10856] Splat with empty keyword args gives unexpected results 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: , Errors-To: ruby-core-bounces@ruby-lang.org Sender: "ruby-core" Issue #10856 has been updated by Tymon Tobolski. Hi Matz, I think I just found a real-world use-case for exactly this issue - please take a look at the (simplified) example below. ~~~ruby class Dispatcher def call(event, args) public_send(event, **args) end def first_event(myarg:) # ... end def second_event # ... end end ~~~ And the call site looks like this: ~~~ruby disp = Dispatcher.new disp.call(params[:event], params[:args]) ~~~ Then we can observe: ~~~ruby disp.call(:first_event, {myarg: 123}) # => passes correctly, all good disp.call(:first_event, {}) # => missing keyword: myarg - exactly what I'd expect disp.call(:first_event, {myarg: 123, other: "foo"}) # => unknown keyword: other - exactly what I'd expect disp.call(:second_event, {}) # => wrong number of arguments (1 for 0) - this /should/ just pass without error ~~~ So, in case the `params[:args]` is empty we would expect to either get a "missing keyword" exception or simply valid method execution when such param is not required. Please let me know what do you think about it. ---------------------------------------- Bug #10856: Splat with empty keyword args gives unexpected results https://bugs.ruby-lang.org/issues/10856#change-53720 * Author: Sean Griffin * Status: Open * Priority: Normal * Assignee: * ruby -v: ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-darwin13] * Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN ---------------------------------------- When keyword args are passed to a method with splat, and there are no keyword args, an empty hash is sent. I would expect no argument to be given, same as splat with an empty array. For example: def foo end foo(**{}) This causes an argument error, as an empty hash is passed. I would expect the same behavior as def foo end foo(*[]) -- https://bugs.ruby-lang.org/