From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-2.5 required=3.0 tests=AWL,BAYES_00, DKIM_ADSP_CUSTOM_MED,FORGED_GMAIL_RCVD,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY shortcircuit=no autolearn=no autolearn_force=no version=3.4.2 Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by dcvr.yhbt.net (Postfix) with ESMTP id C9F2D1F9FD for ; Fri, 12 Mar 2021 20:40:40 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id BE5A6120B04; Sat, 13 Mar 2021 05:39:40 +0900 (JST) Received: from xtrwkhkc.outbound-mail.sendgrid.net (xtrwkhkc.outbound-mail.sendgrid.net [167.89.16.28]) by neon.ruby-lang.org (Postfix) with ESMTPS id 7B468120B02 for ; Sat, 13 Mar 2021 05:39:38 +0900 (JST) Received: by filterdrecv-p3las1-c477c4585-v57kk with SMTP id filterdrecv-p3las1-c477c4585-v57kk-19-604BD1BB-92 2021-03-12 20:40:27.916967665 +0000 UTC m=+2670763.070653732 Received: from herokuapp.com (unknown) by ismtpd0152p1iad2.sendgrid.net (SG) with ESMTP id HOTyjL5gR-2zjzOMfh5_Kw for ; Fri, 12 Mar 2021 20:40:27.807 +0000 (UTC) Date: Fri, 12 Mar 2021 20:40:27 +0000 (UTC) From: xtkoba+ruby@gmail.com Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 78871 X-Redmine-Project: ruby-master X-Redmine-Issue-Tracker: Bug X-Redmine-Issue-Id: 17719 X-Redmine-Issue-Author: nobu X-Redmine-Sender: xtkoba 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: =?us-ascii?Q?75w3+RXRrinEP3ykAS=2F1WzD2vTMrJdTeEiaFbXc9IwWMEh1hfSCCrCFhSSC1lm?= =?us-ascii?Q?uLZ2qQ=2FAdHIMrfyEJkSM2y7lFGn8=2FdKv8EZ069e?= =?us-ascii?Q?SbYRxziZ0pprIfJFFIUZTJ+WrkFTDk5y+fhRzC+?= =?us-ascii?Q?IcjhEMsFRrbiTsqAHWfWClvx3xabbWqV7fUOBcZ?= =?us-ascii?Q?DYisTaZ9FrzmKzD7to3PW54Ub0SqVVZRdTAyy1l?= =?us-ascii?Q?y0XSlsqJQf2vIaIH4=3D?= To: ruby-core@ruby-lang.org X-Entity-ID: b/2+PoftWZ6GuOu3b0IycA== X-ML-Name: ruby-core X-Mail-Count: 102836 Subject: [ruby-core:102836] [Ruby master Bug#17719] Irregular evaluation order in hash literals 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 #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/