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)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 9646C1F4CC for ; Wed, 18 Dec 2024 06:19:54 +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=hMK04YRg; 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=e6zSp9iS; dkim-atps=neutral DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ml.ruby-lang.org; s=mail; t=1734502761; bh=iGhVcm/XolLWApArLcVHq8dW22IZA+2jCrxcjHXMIB4=; 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=hMK04YRghB5e1/MlJlvHwYO69N8IxKkfb0uEsYSADux1OP7wiZtGtejMaJm0O4nvP zO9H2mRk0h5jOX/RRucnFMfa4bEOk4Vk4oU7QyygnhpkTiMrSqEVGKte452bvpEixJ mN1cMbvHC5Ksi1eyS0APsKGfl2g1l5NB4DFjLeI0= Received: from nue.mailmanlists.eu (localhost [IPv6:::1]) by nue.mailmanlists.eu (Postfix) with ESMTP id 77DE244F10 for ; Wed, 18 Dec 2024 06:19:21 +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=e6zSp9iS; dkim-atps=neutral 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 4F9EF44BFD for ; Wed, 18 Dec 2024 06:19:18 +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=TBYpUIbvHvFzoeOND0O9JWW62RBybLXDptzJU9f/Uq0=; b=e6zSp9iSRfdby11xAPJZIs/tVInDHVpaM5keGlqHcw9sOPlyTe2B35WMA6sTav91l3ds guoQpmREuNeqWB6182qw/LEKyIPPmItVwfshG3+I3s//ugQYWHGmXRyk0z/tdAbY6u88AZ H/l/kLc6u7NlUBsLgIe+vvYyczwotIm3bQM7gooA7hXhLaHfe7EdTMQqYTa4YltikOaF4Y W//aJ+tRNH6EfALJMT2ROhoGAiz+fP4wzw168QVKvUR9yuPuZaeNVrFog6TrWOkGcsZd/C qF6thAAJeQhe42eIougYJst6Sa/WpJ/dNTqYPD2eQN0wwhbw7tpUCXbqrJK1twNQ== Received: by recvd-5f54b5d587-fjhb9 with SMTP id recvd-5f54b5d587-fjhb9-1-67626964-B 2024-12-18 06:19:16.708113302 +0000 UTC m=+2883440.193279054 Received: from herokuapp.com (unknown) by geopod-ismtpd-37 (SG) with ESMTP id _b966zUQR3isH4455nz-Lg for ; Wed, 18 Dec 2024 06:19:16.655 +0000 (UTC) Date: Wed, 18 Dec 2024 06:19:16 +0000 (UTC) Message-ID: References: Mime-Version: 1.0 X-Redmine-Project: ruby-master X-Redmine-Issue-Tracker: Bug X-Redmine-Issue-Id: 20943 X-Redmine-Issue-Author: nobu X-Redmine-Issue-Priority: Normal X-Redmine-Sender: matz 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: 96968 X-SG-EID: =?us-ascii?Q?u001=2Eqca74XLbbBG2T0HhbEZgBN9E1Qhb0c7bGBe1waNAWdTreSqyWPDekZUgq?= =?us-ascii?Q?NYk4+nm=2F0VIqwc8ZBTQxqk7G=2FctsRLtYG2yTl=2FP?= =?us-ascii?Q?2CaGNETxG2Rr9Toj9Yj4rQaxLsGHD3EgWkTFN18?= =?us-ascii?Q?xplb7rbOsf4A+vU7Jf2C0GbBAmwqh5h92KsAhM2?= =?us-ascii?Q?j=2FJ9B52h5ERQaIo7liOAnHdOsWsQE9977QtnmHo?= =?us-ascii?Q?KIsACL6rwWiW=2FLZSab345HfuvrsIBHnaqYclbJh?= =?us-ascii?Q?CGDLtBeTw8nu7RcawQvuigRe6A=3D=3D?= To: ruby-core@ml.ruby-lang.org X-Entity-ID: u001.I8uzylDtAfgbeCOeLBYDww== Message-ID-Hash: 3K4DN6TNTGEC6OLSNINIWPV4RAJ2DZAZ X-Message-ID-Hash: 3K4DN6TNTGEC6OLSNINIWPV4RAJ2DZAZ 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:120291] [Ruby master Bug#20943] Constant defined in `Data.define` block List-Id: Ruby developers Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: "matz (Yukihiro Matsumoto) via ruby-core" Cc: "matz (Yukihiro Matsumoto)" Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Issue #20943 has been updated by matz (Yukihiro Matsumoto). Blocks do not introduce new scope even with `instance_eval` nor `class_eval` (along with `Data.define` etc. with blocks). Changing this behavior might cause serious compatibility problems. If someone is willing to survey and estimate how much influence it could cause, we'd like to discuss. Otherwise, it's safe to keep the behavior as it is. Matz. ---------------------------------------- Bug #20943: Constant defined in `Data.define` block https://bugs.ruby-lang.org/issues/20943#change-111056 * Author: nobu (Nobuyoshi Nakada) * Status: Open * Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN ---------------------------------------- >>From https://github.com/ruby/ruby/pull/12274: > A couple times in code review I've seen constants inadvertently leak to top level from within a `Struct` or `Data` do block. I think it would be nice to show reopening the `Data` class when a constant is defined, so the constant is defined within the namespace. In this case, `Measure::NONE` instead of top level `Object::NONE`. It would also show readers that it's okay to reopen a `Data` class, which seems nice since some folk might not realize. Thanks for considering! However, I think that `NONE` probably might be intended to be defined under `Measure`. Current: ```ruby Measure = Data.define(:amount, :unit) do NONE = Data.define end p NONE #=> NONE ``` Another: ```ruby Measure = Data.define(:amount, :unit) do NONE = Data.define p NONE #=> Measure::NONE end p NONE # uninitialized constant NONE (NameError) ``` @zverok How do think? -- 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/