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.8 required=3.0 tests=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 C21EC1F4B4 for ; Wed, 30 Sep 2020 13:14:42 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 6FB21120A80; Wed, 30 Sep 2020 22:14:06 +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 5DB69120A42 for ; Wed, 30 Sep 2020 22:14:04 +0900 (JST) Received: by filterdrecv-p3iad2-df8579867-kdtfn with SMTP id filterdrecv-p3iad2-df8579867-kdtfn-19-5F7484BD-18 2020-09-30 13:14:37.266006767 +0000 UTC m=+746165.548903089 Received: from herokuapp.com (unknown) by ismtpd0066p1mdw1.sendgrid.net (SG) with ESMTP id C3djSFuuR-WpjpqgnHh5Pg for ; Wed, 30 Sep 2020 13:14:37.131 +0000 (UTC) Date: Wed, 30 Sep 2020 13:14:37 +0000 (UTC) From: timhwang21@gmail.com Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 76077 X-Redmine-Project: ruby-master X-Redmine-Issue-Tracker: Bug X-Redmine-Issue-Id: 17205 X-Redmine-Issue-Author: timhwang21 X-Redmine-Sender: timhwang21 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?nhHOxy0wR9038I4aYl8RQTVTwer2qshDU1FE9kLvMZM7OF7KZaSy17NVITsMQP?= =?us-ascii?Q?2n46AVAMS9VPr6A2S29ps9jYrOdWsQMvAG54k=2FS?= =?us-ascii?Q?s51n+Qs=2F5plHRsuohHNqmNlkZj7AIR1sSdaxA5J?= =?us-ascii?Q?hD4oIeFWFu4bnCwF7q6hUXhXSTxvZzd5heKYY06?= =?us-ascii?Q?YLHtFAz0KO059c=2F52ZBKXifxdjwavQYRCu=2FOLA4?= =?us-ascii?Q?w5NTIsghVt31Ie5z4=3D?= To: ruby-core@ruby-lang.org X-ML-Name: ruby-core X-Mail-Count: 100236 Subject: [ruby-core:100236] [Ruby master Bug#17205] Misleading error message when comparing NaN with numbers in array 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 #17205 has been reported by timhwang21 (Tim Hwang). ---------------------------------------- Bug #17205: Misleading error message when comparing NaN with numbers in array https://bugs.ruby-lang.org/issues/17205 * Author: timhwang21 (Tim Hwang) * Status: Open * Priority: Normal * ruby -v: ruby 3.0.0dev (2020-09-30T11:43:19Z master 65e8a29389) [x86_64-darwin19] * Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN ---------------------------------------- The closest issue I could find is this: https://bugs.ruby-lang.org/issues/10424 There is quite a lot of inconsistency when dealing with arrays containing `NaN`, dependent on 1) if comparing against an integer or a float, 2) order of comparison. The one that stands out to me as "least correct" is the last one (`[Float::NAN, 1.0].min`) which raises `TypeError (no implicit conversion from nil to integer)`. ``` ruby # .sort [1, Float::NAN].sort # Most sensible error message # ArgumentError (comparison of Integer with NaN failed) [1.0, Float::NAN].sort # Somewhat sensible error message # TypeError (no implicit conversion from nil to integer) [Float::NAN, 1].sort # Somewhat sensible error message # TypeError (no implicit conversion from nil to integer) [Float::NAN, 1.0].sort # Somewhat sensible error message # TypeError (no implicit conversion from nil to integer) # .min [1, Float::NAN].min # Most sensible error message # ArgumentError (comparison of Float with 1 failed) [1.0, Float::NAN].min # Somewhat sensible error message # TypeError (no implicit conversion from nil to integer) [Float::NAN, 1].min # Most sensible error message # ArgumentError (comparison of Integer with NaN failed) [Float::NAN, 1.0].min # Very misleading error message # TypeError (no implicit conversion from nil to integer) ``` -- https://bugs.ruby-lang.org/