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-ASN: AS24940 94.130.0.0/16 X-Spam-Status: No, score=-3.0 required=3.0 tests=AWL,BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_BL_SPAMCOP_NET,RCVD_IN_DNSWL_HI, SPF_HELO_PASS,SPF_PASS,UNPARSEABLE_RELAY shortcircuit=no autolearn=no autolearn_force=no version=3.4.2 Received: from nue.mailmanlists.eu (nue.mailmanlists.eu [94.130.110.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 4676E1F601 for ; Mon, 5 Dec 2022 14:37:42 +0000 (UTC) Authentication-Results: dcvr.yhbt.net; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=ruby-lang.org header.i=@ruby-lang.org header.b="TdI1P5CM"; dkim-atps=neutral Received: from nue.mailmanlists.eu (localhost [127.0.0.1]) by nue.mailmanlists.eu (Postfix) with ESMTP id 537427E80C; Mon, 5 Dec 2022 14:37:35 +0000 (UTC) Authentication-Results: nue.mailmanlists.eu; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=ruby-lang.org header.i=@ruby-lang.org header.a=rsa-sha256 header.s=s1 header.b=TdI1P5CM; dkim-atps=neutral Received: from xtrwkhkc.outbound-mail.sendgrid.net (xtrwkhkc.outbound-mail.sendgrid.net [167.89.16.28]) by nue.mailmanlists.eu (Postfix) with ESMTPS id 14E527E5E1 for ; Mon, 5 Dec 2022 14:37:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ruby-lang.org; h=from:references:subject:mime-version:content-type: content-transfer-encoding:list-id:to:cc:content-type:from:subject:to; s=s1; bh=919zxay9KdFgBUw9EhOxYMmgrlEIpUc2T4cpfo6CU5c=; b=TdI1P5CM5SIr7J1fENIdsevKv5h7W1XxvtrF6zcS+pTgJXZvMbMbidwtl34MtVq7mtHN nIcuJEKtUI/67zmTwRvVOiwxOVEP0g0yikF60SdFVPpIeusu6MewTgCnRWR9GHZQ2uN7G3 PqdFxE42sIJH2+wBn6eBDvCOH8k/b2TsJVNUfZhDForV7Awp/Lj6Ln+YBTDCjFbXkhQ6TY AM+1KE0C30pQybHqCNZWBnkIFNmhIUb2lHJvBxEzdoSI1lxJK+Z+dh8hFCtonYK3dwyS+O 8vHzrPo/SpPdUTvhEcdOnMimv6aanAubMi1nW9LKvFBSiZNJa0lRTjZD6luniMFg== Received: by filterdrecv-6c4ccfbdd8-6sbcc with SMTP id filterdrecv-6c4ccfbdd8-6sbcc-1-638E022A-9 2022-12-05 14:37:30.203095774 +0000 UTC m=+1524718.577232537 Received: from herokuapp.com (unknown) by geopod-ismtpd-6-3 (SG) with ESMTP id p8yAQy1xSyO_dvAEOq2HPg for ; Mon, 05 Dec 2022 14:37:30.100 +0000 (UTC) Date: Mon, 05 Dec 2022 14:37:30 +0000 (UTC) From: "clavius_tales (Clavius Tales Rocha Moreira)" Message-ID: References: Mime-Version: 1.0 X-Redmine-Project: ruby-master X-Redmine-Issue-Tracker: Bug X-Redmine-Issue-Id: 19184 X-Redmine-Issue-Author: clavius_tales X-Redmine-Sender: clavius_tales 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-Redmine-MailingListIntegration-Message-Ids: 87566 X-SG-EID: =?us-ascii?Q?GwKCUyunI75+vF2UPsfPV60Eq63h=2FdNUCgmInUR6sA+ZRlSnqXZM2iP0fDroy8?= =?us-ascii?Q?mzk5hGZI+weZj65xpeWU4X895kl9ghglPJ5w+Tc?= =?us-ascii?Q?P9ww1aZDdivyTZZUY9jDKgoEcthnD+0z9AmNmOh?= =?us-ascii?Q?BenFvv5K2hGt50y8+YlFfgiakHMv+sa1lguuI1N?= =?us-ascii?Q?Aw0tRPaHLV+9gXlpTmSQTzjcpcJECQmI+=2FYLwwG?= =?us-ascii?Q?VLJAP6INeea1hpCKNoLLwaQs1w9tDAUq1sF0D5x?= =?us-ascii?Q?736EVSC44r2Yhml3sDYBR9UTNFuGvs46038qJBU?= =?us-ascii?Q?ZFE=3D?= To: ruby-core@ml.ruby-lang.org X-Entity-ID: b/2+PoftWZ6GuOu3b0IycA== Message-ID-Hash: EVWADOLHUENU3PBUYBRX2DEGU35QLUFS X-Message-ID-Hash: EVWADOLHUENU3PBUYBRX2DEGU35QLUFS X-MailFrom: bounces+313651-b711-ruby-core=ml.ruby-lang.org@em5188.ruby-lang.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.3 Precedence: list Reply-To: Ruby developers Subject: [ruby-core:111210] [Ruby master Bug#19184] create a Range with String subclass presents a weird behavior List-Id: Ruby developers Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Issue #19184 has been reported by clavius_tales (Clavius Tales Rocha Moreira). ---------------------------------------- Bug #19184: create a Range with String subclass presents a weird behavior https://bugs.ruby-lang.org/issues/19184 * Author: clavius_tales (Clavius Tales Rocha Moreira) * Status: Open * Priority: Normal * ruby -v: 3.1.3 * Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN ---------------------------------------- ``` ruby class CalendarMonth < String def succ self.class.new( if december? "#{year + 1}-01" else "#{year}-#{(month + 1).to_s.rjust(2, '0')}" end ) end private def december? month == 12 end def month self[-2..].to_i end def year self[0..3].to_i end end (CalendarMonth.new('2021-11')..CalendarMonth.new('2022-02')).to_a ``` Running the script above in Ruby 2.7.5, we get: ``` ruby ["2021-11", "2021-12", "2022-01", "2022-02"] ``` Running the same script in Ruby 3.1.3: ```ruby ["2021-11", "2021-12", "2021-13", "2021-14", "2021-15", "2021-16", "2021-17", "2021-18", "2021-19", "2021-20", "2021-21", "2021-22", "2021-23", "2021-24", "2021-25", "2021-26", "2021-27", "2021-28", "2021-29", "2021-30", "2021-31", "2021-32", "2021-33", "2021-34", "2021-35", "2021-36", "2021-37", "2021-38", "2021-39", "2021-40", "2021-41", "2021-42", "2021-43", "2021-44", "2021-45", "2021-46", "2021-47", "2021-48", "2021-49", "2021-50", "2021-51", "2021-52", "2021-53", "2021-54", "2021-55", "2021-56", "2021-57", "2021-58", "2021-59", "2021-60", "2021-61", "2021-62", "2021-63", "2021-64", "2021-65", "2021-66", "2021-67", "2021-68", "2021-69", "2021-70", "2021-71", "2021-72", "2021-73", "2021-74", "2021-75", "2021-76", "2021-77", "2021-78", "2021-79", "2021-80", "2021-81", "2021-82", "2021-83", "2021-84", "2021-85", "2021-86", "2021-87", "2021-88", "2021-89", "2021-90", "2021-91", "2021-92", "2021-93", "2021-94", "2021-95", "2021-96", "2021-97", "2021-98", "2021-99", "2022-00", "2022-01", "2022-02"] ``` I know it's not a good modeling inherit from String class, but... -- https://bugs.ruby-lang.org/ ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/