From: mame@ruby-lang.org
To: ruby-core@ruby-lang.org
Subject: [ruby-core:88785] [Ruby trunk Bug#15052] must not optimize `foo(**{})` out
Date: Fri, 31 Aug 2018 12:09:43 +0000 (UTC) [thread overview]
Message-ID: <redmine.issue-15052.20180831120941.9c9696203bce3df3@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-15052.20180831120941@ruby-lang.org
Issue #15052 has been reported by mame (Yusuke Endoh).
----------------------------------------
Bug #15052: must not optimize `foo(**{})` out
https://bugs.ruby-lang.org/issues/15052
* Author: mame (Yusuke Endoh)
* Status: Open
* Priority: Normal
* Assignee:
* Target version:
* ruby -v:
* Backport: 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN
----------------------------------------
A keyword rest argument with empty hash, `**{}`, is removed during parsing phase. However, under the current spec of keyword parameters, this leads to a problem:
```
def foo(opt = "opt", **hsh)
p [opt, hsh]
end
foo({}, **{}) #=> expected: [{}, {}], actual: ["opt", {}]
```
`foo({}, **{})` is obviously expected to pass the first `{}` to `opt`, and the second `**{}` to `**hsh`. However, `**{}` is removed at parsing phase, sp the first `{}` is considered as a keyword rest argument, which causes the above strange result.
So, we cannot optimize `**{}` out, unless keyword argument is separated from normal arguments #14183. (The current spec is really intractable not only for Ruby users but also for Ruby developers!)
---Files--------------------------------
do-not-optimize-keyword-argument-with-empty-hash.patch (717 Bytes)
--
https://bugs.ruby-lang.org/
next parent reply other threads:[~2018-08-31 12:09 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <redmine.issue-15052.20180831120941@ruby-lang.org>
2018-08-31 12:09 ` mame [this message]
2019-10-17 22:05 ` [ruby-core:95405] [Ruby master Bug#15052] must not optimize `foo(**{})` out merch-redmine
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.ruby-lang.org/en/community/mailing-lists/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=redmine.issue-15052.20180831120941.9c9696203bce3df3@ruby-lang.org \
--to=ruby-core@ruby-lang.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).