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=-1.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,SPF_HELO_PASS,SPF_PASS autolearn=ham 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) server-digest SHA256) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 28B941F44D for ; Tue, 23 Apr 2024 06:21:59 +0000 (UTC) Authentication-Results: dcvr.yhbt.net; dkim=pass (1024-bit key; secure) header.d=ml.ruby-lang.org header.i=@ml.ruby-lang.org header.a=rsa-sha256 header.s=mail header.b=KgwYiJS5; 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=Mb3Qw2Go; dkim-atps=neutral Received: from nue.mailmanlists.eu (localhost [127.0.0.1]) by nue.mailmanlists.eu (Postfix) with ESMTP id E0ED084468; Tue, 23 Apr 2024 06:21:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ml.ruby-lang.org; s=mail; t=1713853310; bh=a/A6V1d34Hx7DMLPRLrrWq2oGms/cTrj7DkptMobIk4=; 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=KgwYiJS5DwL1nIXOC34a1Xe6P7fp5rKoJnEhkoAbaM2ePTqKCkvXTvAKdkVl83x1e ufEcU5eWDtdYf+IhsvVgrOYq0/M60fU1lwqy0ezinNT96NDxnCqMLabZ70VN0dzibk +ubOTZpysPpL+iBcwarKDgqorOW34BTJC8Q7uxLs= Received: from s.wrqvtbkv.outbound-mail.sendgrid.net (s.wrqvtbkv.outbound-mail.sendgrid.net [149.72.123.24]) by nue.mailmanlists.eu (Postfix) with ESMTPS id 69D7684307 for ; Tue, 23 Apr 2024 06:21:47 +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=Mb3Qw2Go; dkim-atps=neutral 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=NGbunu3PO1r2khKf5FohsoVsLdXC8PGfc8xeU1TIEOg=; b=Mb3Qw2Goyuv0l758cq7alXPfu5PHOlClIpQDHhjLhDefkpAGMCj/7extSAh40U8zHSmQ 3CaJgL4nJt3BJw6zPC2VNRq+lJIBa+9D9zxpNkzGw/bnwfEyCEDh/unHDmGBazRBGTpYKA WGhTO7QGGzAJEKgf4fc6uF73t+IOUtFxVSh91GEBcWwPtcSVYFj7Ji5PO75TsbVHQcx7Jn AyKcGXJI6N0uBr/c4lL3f2Srq8GuQs2PzvGWgbtnhVi8V9sx0OZiWl3dkt5W+W0K0OE1nW KQOwJKT8hQFhf0h9C7U3ECc9q0dho9gbb3BTirPILPPH6KLXfbRQoY2VgCNzxiJA== Received: by recvd-547d99795c-jdrrf with SMTP id recvd-547d99795c-jdrrf-1-6627537A-3 2024-04-23 06:21:46.198439151 +0000 UTC m=+894096.455109387 Received: from herokuapp.com (unknown) by geopod-ismtpd-7 (SG) with ESMTP id jm0fMKUQSTCdc5eDo4c78A for ; Tue, 23 Apr 2024 06:21:46.174 +0000 (UTC) Date: Tue, 23 Apr 2024 06:21:46 +0000 (UTC) Message-ID: References: Mime-Version: 1.0 X-Redmine-Project: ruby-master X-Redmine-Issue-Tracker: Bug X-Redmine-Issue-Id: 20444 X-Redmine-Issue-Author: esad X-Redmine-Issue-Priority: Normal X-Redmine-Sender: esad 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: 94246 X-SG-EID: =?us-ascii?Q?u001=2ElMtbztYvHZZZvM524qPN0nU7mdj2wbw4OeavLHeQrlG0ZCx2PWmBPGCch?= =?us-ascii?Q?4=2FXCz8t31i+kRsvxV75BGyB0WhcpS3Ai1n9eaWt?= =?us-ascii?Q?fDP=2Fjb=2FX=2FOqRAj9P21yHYW7jcE0GMLe3t8U819h?= =?us-ascii?Q?NvBddBxDu02HVUnoTJle+MRSyKn82q+v8g+2mtx?= =?us-ascii?Q?kZONMK1rEajRNab01jDTBnmSYrr+uFHO51SjYH+?= =?us-ascii?Q?hWJvdyZ1mMfTcabVCi68i=2FeWPF0LDKS5MnLuHTM?= =?us-ascii?Q?FfByuuiZABAfWk2Z4lrFcZCxjw=3D=3D?= To: ruby-core@ml.ruby-lang.org X-Entity-ID: u001.I8uzylDtAfgbeCOeLBYDww== Message-ID-Hash: BTPAQK2S2U5BJGB6YMMWEXTPSBGMLO25 X-Message-ID-Hash: BTPAQK2S2U5BJGB6YMMWEXTPSBGMLO25 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:117650] [Ruby master Bug#20444] Kernel#loop: returning the "result" value of StopIteration doesn't work when raised directly List-Id: Ruby developers Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: "esad (Esad Hajdarevic) via ruby-core" Cc: "esad (Esad Hajdarevic)" Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Issue #20444 has been updated by esad (Esad Hajdarevic). nobu (Nobuyoshi Nakada) wrote in #note-1: > `StopIteration.new(3)` does not set `result`, and no way to set it in Ruby level. > > ``` > $ ruby -e 'e = StopIteration.new(3); p e.message, e.result' > "3" > nil > ``` Thanks for the hint. It seems that subclassing StopIteration to provide result works: ``` class MyException < StopIteration def result = 5 end loop { raise MyException } # => 5 ``` ---------------------------------------- Bug #20444: Kernel#loop: returning the "result" value of StopIteration doesn't work when raised directly https://bugs.ruby-lang.org/issues/20444#change-108060 * Author: esad (Esad Hajdarevic) * Status: Closed * ruby -v: ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [arm64-darwin20] * Backport: 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN ---------------------------------------- There was a https://bugs.ruby-lang.org/issues/11498 a while ago which was merged in, but I was surprised to find out that raising `StopIteration` in a loop like `loop { raise StopIteration.new(3) }` returns nil and not 3. -- 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/