From: mame@ruby-lang.org
To: ruby-core@ruby-lang.org
Subject: [ruby-core:94423] [Ruby master Bug#16111] Combining default positional and keyword arguments is resulting in a `to_hash` method call
Date: Mon, 19 Aug 2019 06:13:06 +0000 (UTC) [thread overview]
Message-ID: <redmine.journal-80848.20190819061305.7f6ee0c38c93577f@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-16111.20190819054734@ruby-lang.org
Issue #16111 has been updated by mame (Yusuke Endoh).
> I would like to know why the method to_hash is being called
A method call that accepts keywords checks if the last argument is a Hash or not. The check includes attempting to convert it by using `to_hash`. This is the behavior you are seeing.
I agree that it is very strange. It is elegantly solved if we can separate positional and keyword arguments completely (#14183), but the separation seems to be difficult because the incompatibility is painful.
----------------------------------------
Bug #16111: Combining default positional and keyword arguments is resulting in a `to_hash` method call
https://bugs.ruby-lang.org/issues/16111#change-80848
* Author: mtelford (Michael Telford)
* Status: Open
* Priority: Normal
* Assignee:
* Target version:
* ruby -v: 2.6.3
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN
----------------------------------------
Combining default positional and keyword arguments is resulting in a `to_hash` method call when I don't believe it should be. It's affecting some code I am writing. The full details of the behaviour I'm describing can be seen in the attached script.
I would like to know why the method `to_hash` is being called (only in certain circumstances) and if this is a bug to be fixed or desired behaviour (and why?).
Thank in advance!
---Files--------------------------------
ruby-bug.rb (1.44 KB)
--
https://bugs.ruby-lang.org/
next prev parent reply other threads:[~2019-08-19 6:13 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <redmine.issue-16111.20190819054734@ruby-lang.org>
2019-08-19 5:47 ` [ruby-core:94422] [Ruby master Bug#16111] Combining default positional and keyword arguments is resulting in a `to_hash` method call michael.telford
2019-08-19 6:13 ` mame [this message]
2019-08-19 8:22 ` [ruby-core:94429] " michael.telford
2019-08-19 16:45 ` [ruby-core:94437] " shevegen
2019-08-20 14:26 ` [ruby-core:94446] " michael.telford
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.journal-80848.20190819061305.7f6ee0c38c93577f@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).