From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on starla X-Spam-Level: X-Spam-Status: No, score=0.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_BL_SPAMCOP_NET,SPF_HELO_PASS, SPF_PASS autolearn=no autolearn_force=no version=3.4.6 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)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 999611F4CC for ; Thu, 9 Jan 2025 11:42:09 +0000 (UTC) Authentication-Results: dcvr.yhbt.net; dkim=pass (1024-bit key; unprotected) header.d=ml.ruby-lang.org header.i=@ml.ruby-lang.org header.a=rsa-sha256 header.s=mail header.b=M3JlK4cX; 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=LpeMfmH3; dkim-atps=neutral DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ml.ruby-lang.org; s=mail; t=1736422927; bh=FFGkz/puGI59tOXrgRF55+ia80O5ruu7v6O+bI6K1Q0=; h=Date:References:To:Reply-To:Subject:List-Id:List-Archive: List-Help:List-Owner:List-Post:List-Subscribe:List-Unsubscribe: From:Cc:From; b=M3JlK4cXHU+pA4/aXLksWVrW17z+6AI6x0M0WD3IGsYcr9WaUi08dk17qwjnbYWd3 MwSFQ5xjJC7mva/op/V/hyue6+iduT/Dg5Fu2+v9SmlPO3xXCnqFf01Z2ZyYIX/MG2 RBh/LUVH028lauvV7wotD1HzPAP2xqM4lIe7aa9c= Received: from nue.mailmanlists.eu (localhost [IPv6:::1]) by nue.mailmanlists.eu (Postfix) with ESMTP id 6C0494681F for ; Thu, 9 Jan 2025 11:42:07 +0000 (UTC) Authentication-Results: nue.mailmanlists.eu; dkim=pass (2048-bit key; unprotected) header.d=ruby-lang.org header.i=@ruby-lang.org header.a=rsa-sha256 header.s=s1 header.b=LpeMfmH3; dkim-atps=neutral Received: from s.wrqvwxzv.outbound-mail.sendgrid.net (s.wrqvwxzv.outbound-mail.sendgrid.net [149.72.154.232]) by nue.mailmanlists.eu (Postfix) with ESMTPS id 3391F467BC for ; Thu, 9 Jan 2025 11:42:02 +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=KkUyNovg/TwH567RHNjRKGT2L68k/0qdB4v0gYdmtds=; b=LpeMfmH3PuCbf8dzwz/JKyO4Iv9LRP0KqofmtOZTAKJhoGmrINZlwknq0geZB1XYQoRl gW11o+udUyksWKuuEUwBCKORD9shD8/PIv+KaFFZHw1BkZWS5qe2ozzC91M9+l5cfPRKVn WkTFwnFVIml1DMnA7NG4TPFr4cnRMWSWJukQG/GVber22foxyq5jhKx5YqO2ArKlbz5L6f oAqlidwlcYKdAyyFi1rE/ltpJAZTE6H66y3rJ1Tg8I43zmWhq0QE0RVTeoUvthCHNfqb6b Gz6T/O8mL3MN4Yc8/KAZK5sBuziw5S/tpMJ17qJLKnl3ULhzxyiXPi3sHlDXR94g== Received: by recvd-84b546689d-997dv with SMTP id recvd-84b546689d-997dv-1-677FB608-10 2025-01-09 11:42:00.479345187 +0000 UTC m=+4803581.944680629 Received: from herokuapp.com (unknown) by geopod-ismtpd-36 (SG) with ESMTP id mi429CecRf-8YTcwF_vErQ for ; Thu, 09 Jan 2025 11:42:00.423 +0000 (UTC) Date: Thu, 09 Jan 2025 11:42:00 +0000 (UTC) Message-ID: References: Mime-Version: 1.0 X-Redmine-Project: ruby-master X-Redmine-Issue-Tracker: Bug X-Redmine-Issue-Id: 20980 X-Redmine-Issue-Author: zverok X-Redmine-Issue-Priority: Normal X-Redmine-Sender: mame 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: 97255 X-SG-EID: =?us-ascii?Q?u001=2Ep+ckLDtT+4Y5c+H0YCkEnsuWiCQmn3OZA=2F9FzjoR6ZZlPaMv54M7EFoSM?= =?us-ascii?Q?CX5Trc79ep2R5F+0oYS4n23jq1cv5yLqFR8Yzay?= =?us-ascii?Q?hpwidwndoqXN5ROxKAih+N92fFA0jvgvnqjU0ci?= =?us-ascii?Q?rbBvR3lIJwHGqSkBr7lNFHMQMzFO7neRGum1xaV?= =?us-ascii?Q?HwGp=2F=2F26Q2aNlu6C+wvg7+LV7drEHoZfeyknivh?= =?us-ascii?Q?fbWaomkxETSxms3vDyEo5sCzy2jDXEUzYe0LihN?= =?us-ascii?Q?Y5Xk?= To: ruby-core@ml.ruby-lang.org X-Entity-ID: u001.I8uzylDtAfgbeCOeLBYDww== Message-ID-Hash: 4JGIXUMGDD7Z5BFZN5PX6DZTA5W5KVBI X-Message-ID-Hash: 4JGIXUMGDD7Z5BFZN5PX6DZTA5W5KVBI 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.9 Precedence: list Reply-To: Ruby developers Subject: [ruby-core:120571] [Ruby master Bug#20980] Range#size new TypeError vs semi-open ranges List-Id: Ruby developers Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: "mame (Yusuke Endoh) via ruby-core" Cc: "mame (Yusuke Endoh)" Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Issue #20980 has been updated by mame (Yusuke Endoh). Status changed from Open to Closed The current behavior is intended. In principle, `#size` should return how many times `#each` will call a given block. (It could return nil as unknown.) Since beginless range does not respond to `#each`, it is now natural for `#size` to raise an exception. @naruse said he will try improving the document. ---------------------------------------- Bug #20980: Range#size new TypeError vs semi-open ranges https://bugs.ruby-lang.org/issues/20980#change-111395 * Author: zverok (Victor Shepelev) * Status: Closed * ruby -v: ruby 3.4.0dev (2024-12-24T14:40:12Z master 07e89bde46) +PRISM [x86_64-linux] * Backport: 3.1: DONTNEED, 3.2: DONTNEED, 3.3: DONTNEED ---------------------------------------- Since #18984, `Range#size` throws `TypeError` if the `begin` is not iterable (doesn't respond to `#succ`). It produces one small inconvenience compared to 3.3: ```ruby ('a'..).size #=> nil (..'a').size # 3.3: nil # 3.4: can't iterate from NilClass (TypeError) -- well, probably makes sense # BUT: (3..).size #=> Infinity -- cool! (..3).size # 3.3: Infinity -- reasonable? # 3.4: can't iterate from NilClass (TypeError) -- worse? ``` I believe that while 3.4's behavior is explainable, 3.3's one has better DX. (Obviously too late to change before the release, but maybe might be considered for some patch version or Ruby 3.5?..) -- 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/lists/ruby-core.ml.ruby-lang.org/