From: xtkoba+ruby@gmail.com
To: ruby-core@ruby-lang.org
Subject: [ruby-core:102836] [Ruby master Bug#17719] Irregular evaluation order in hash literals
Date: Fri, 12 Mar 2021 20:40:27 +0000 (UTC) [thread overview]
Message-ID: <redmine.journal-90894.20210312204026.4@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-17719.20210312130546.4@ruby-lang.org
Issue #17719 has been updated by xtkoba (Tee KOBAYASHI).
To me the evaluation order of 1->3->2 is a bit unexpected, but it might be OK unless specified otherwise.
IMO, duplicate keys in hash literals should be allowed in a scripting language like Ruby. For example, they are explicitly allowed in another scripting language named Python [1]. On the other hand, compiled languages should disallow them.
[1] https://mail.python.org/pipermail/python-ideas/2019-March/055726.html
----------------------------------------
Bug #17719: Irregular evaluation order in hash literals
https://bugs.ruby-lang.org/issues/17719#change-90894
* Author: nobu (Nobuyoshi Nakada)
* Status: Open
* Priority: Normal
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN
----------------------------------------
@mame pointed out an irregular evaluation order example.
```sh
$ ruby -e '{foo:p(1), bar:p(2), foo:p(3)}'
-e:1: warning: key :foo is duplicated and overwritten on line 1
1
3
2
```
It feels like a bug.
https://github.com/nobu/ruby/tree/duplicated-keys-order
Or, probably it would be better to turn into an error?
--
https://bugs.ruby-lang.org/
next prev parent reply other threads:[~2021-03-12 20:40 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-12 13:05 [ruby-core:102831] [Ruby master Bug#17719] Irregular evaluation order in hash literals nobu
2021-03-12 20:40 ` xtkoba+ruby [this message]
2021-07-15 6:22 ` [ruby-core:104611] " nobu
2021-10-14 22:55 ` [ruby-core:105636] " jeremyevans0 (Jeremy Evans)
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-90894.20210312204026.4@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).