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) server-digest SHA256) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 676B41F4BE for ; Tue, 15 Oct 2024 18:03:00 +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=ET0byYsX; 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=ACFxpdCh; dkim-atps=neutral DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ml.ruby-lang.org; s=mail; t=1729015378; bh=KYrfsF2ky/kYVKoIgFcQLKSYNMkEDXVz1nqtwu5FfwA=; 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=ET0byYsXweeijsQZ1eB+61V98POCZDe3i76Zwc7zZ3gHh4i2MWRy4D7MHnPAwdGR+ 7yr8C0F3gc7NtSPbCU6/wWOGTq9s1VRnaLnxH8ctArF0iUDKqS+gepZw0sLjiT5qCT WPmaBcw7uM7GfDkrKyLTYauQICwskiCYQXbedp4w= Received: from nue.mailmanlists.eu (localhost [IPv6:::1]) by nue.mailmanlists.eu (Postfix) with ESMTP id 217EE4408D for ; Tue, 15 Oct 2024 18:02:58 +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=ACFxpdCh; dkim-atps=neutral Received: from s.wrqvtvvn.outbound-mail.sendgrid.net (s.wrqvtvvn.outbound-mail.sendgrid.net [149.72.120.130]) by nue.mailmanlists.eu (Postfix) with ESMTPS id 3F6B043FE0 for ; Tue, 15 Oct 2024 18:02:47 +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=cy6XQS1pz6Tz+Mf6CDRpCtn2zxrnzhPpCbH0R+gn8xQ=; b=ACFxpdChgIn46smqhee1UADxQvKF9vjHF2CT9MJp9tCZysk+USM12PlCpBNcwJ+MX+PN uhCafkLGJKon4bvr9kXEp1qc/kZdZxlA1i9Kl7NICifCDv8iowmep4r1fUPXj6lVFyf8DB Cdn64MKSdK57Ofh+tDkmBv5WbDdHVFxY0vFvYgo+LrezBPvlpTCJxMxYlIjNG5mG7Ll4ev NwO7pxk3lPRcgnkEFV3yZ9tA0t5zdvLakNfuDXJ8TS36/Reglo/dsiyvCCYJFcjjyfo59L Sj63UqEroRr4c/EyaAgUKYTumWPkZ/EwiLvF3fzEY931Pvs8RUkqQkL5ktG26f4w== Received: by recvd-5577bcb48c-rmksz with SMTP id recvd-5577bcb48c-rmksz-1-670EAE46-7 2024-10-15 18:02:46.104993081 +0000 UTC m=+2851476.104940212 Received: from herokuapp.com (unknown) by geopod-ismtpd-36 (SG) with ESMTP id 6GU_Isp2SCq81UOjTEG7_g for ; Tue, 15 Oct 2024 18:02:46.070 +0000 (UTC) Date: Tue, 15 Oct 2024 18:02:46 +0000 (UTC) Message-ID: References: Mime-Version: 1.0 X-Redmine-Project: ruby-master X-Redmine-Issue-Tracker: Feature X-Redmine-Issue-Id: 18242 X-Redmine-Issue-Author: danh337 X-Redmine-Issue-Priority: Normal X-Redmine-Sender: danh337 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: 96164 X-SG-EID: =?us-ascii?Q?u001=2Er=2Fc6I3VWKURbMVIQTzDotlzdL1Hz+n5CvbC2B+XH46Z=2FLHlQBvW3GnJrH?= =?us-ascii?Q?NfmHPmiqNcxZdCaoHoXarukl0s6DtuG7X1Miq77?= =?us-ascii?Q?hVpd4VghmmqiXJwnEo8hTs0b1UGNXV92VwWYX3b?= =?us-ascii?Q?LZLETsUWRoEljWkHE75mPoDMBSkWtqVkjiFAPIA?= =?us-ascii?Q?uHB4ocxpQ5UE8kxfMD6NDBsLa2b0dTuFpm+FOAU?= =?us-ascii?Q?40lwhusqx124GPvOHs1yZSoxgSGZUcR3TSkUf2a?= =?us-ascii?Q?V=2FR3?= To: ruby-core@ml.ruby-lang.org X-Entity-ID: u001.I8uzylDtAfgbeCOeLBYDww== Message-ID-Hash: QZI4NMPXKQQ4JITIQVWP5JK3RGJSCJPP X-Message-ID-Hash: QZI4NMPXKQQ4JITIQVWP5JK3RGJSCJPP 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:119530] [Ruby master Feature#18242] Parser makes multiple assignment sad in confusing way List-Id: Ruby developers Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: "danh337 (Dan H) via ruby-core" Cc: "danh337 (Dan H)" Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Issue #18242 has been updated by danh337 (Dan H). These `and` & `or` operators are good things. They are much more readable for one-liners in some cases. @matz @nobu I know you are super busy, but is there any way to move this forward? ---------------------------------------- Feature #18242: Parser makes multiple assignment sad in confusing way https://bugs.ruby-lang.org/issues/18242#change-110144 * Author: danh337 (Dan H) * Status: Open ---------------------------------------- Example: ``` ruby a, b = 2, 1 if 1 < 2 # Works a, b = [2, 1] if 1 < 2 # Works (a, b) = 2, 1 if 1 < 2 # Works (a, b) = [2, 1] if 1 < 2 # Works (a, b = [2, 1]) if 1 < 2 # Works a, b = 2, 1 unless 2 < 1 # Works a, b = [2, 1] unless 2 < 1 # Works (a, b) = 2, 1 unless 2 < 1 # Works (a, b) = [2, 1] unless 2 < 1 # Works (a, b = [2, 1]) unless 2 < 1 # Works 1 < 2 and a, b = 2, 1 # SyntaxError 1 < 2 and a, b = [2, 1] # SyntaxError 1 < 2 and (a, b) = 2, 1 # SyntaxError 1 < 2 and (a, b) = [2, 1] # SyntaxError (1 < 2) and a, b = 2, 1 # SyntaxError (1 < 2) and a, b = [2, 1] # SyntaxError (1 < 2) and (a, b) = 2, 1 # SyntaxError (1 < 2) and (a, b) = [2, 1] # SyntaxError 1 < 2 and (a, b = 2, 1) # Works 1 < 2 and (a, b = [2, 1]) # Works 2 < 1 or a, b = 2, 1 # SyntaxError 2 < 1 or a, b = [2, 1] # SyntaxError 2 < 1 or (a, b) = 2, 1 # SyntaxError 2 < 1 or (a, b) = [2, 1] # SyntaxError (2 < 1) or a, b = 2, 1 # SyntaxError (2 < 1) or a, b = [2, 1] # SyntaxError (2 < 1) or (a, b) = 2, 1 # SyntaxError (2 < 1) or (a, b) = [2, 1] # SyntaxError 2 < 1 or (a, b = 2, 1) # Works 2 < 1 or (a, b = [2, 1]) # Works ``` Based on the precedence rules I've been able to find, all of these should work. Believe it or not, there are cases where using `and` or `or` in a stanza of lines is much more readable. Should the parser allow all of these? See attached driver script to reproduce this output. ---Files-------------------------------- driver.rb (1.17 KB) and-or-masgn-18242.diff (963 Bytes) driver.rb (2.1 KB) -- 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/