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, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, 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 B79D71F57C for ; Wed, 14 May 2025 04:57: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=m9kh89gV; 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=K+xOljXZ; dkim-atps=neutral DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ml.ruby-lang.org; s=mail; t=1747198670; bh=yJYptvV1hXIjN5YRk42L0PQhFUkUWeX08XRZmny4EBY=; 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=m9kh89gVHv9DosZ+tTazQ1eGewGEZsdjzD51TN1Z70s/4kyBDJT1UenJkvE9KlMQ7 4QsWHJQ+S6dp0zrnVQn35Tss7F1QqsuPNjKHc76HI+4rLbbcw0+FyXAUg1ojf02yyr dGK+bqIzEkim2kZoVICKXzkyJHlrJpk710V382YU= Received: from nue.mailmanlists.eu (localhost [IPv6:::1]) by nue.mailmanlists.eu (Postfix) with ESMTP id 5D9EC474C8 for ; Wed, 14 May 2025 04:57:50 +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=K+xOljXZ; 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 AF3DB467AC for ; Wed, 14 May 2025 04:57:45 +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=JSoB5IFiqrVxYst+i85+un4kJZeYcVOhP0pSR5Grt04=; b=K+xOljXZR1gpAODNhIfTOB6HpRkcc4Q0ycWZbtICfvbVh5YPQq/9IAfumJ3kHPTOk4ex 6bOfMfAK0B70YDa/QrdPTBNnQcsTpaSzc3brumzkRjP7xdneZ+7OkQqzEy+fxetNGpw0Ft NwiIB1be2FUj76oRwk/gYEyLLN4GEaKkUahe/L81s0LDLWiP/4+IWmcUilmWgmeQNuBLB1 4Xcyo0/zDZ3wJgIvH7UQp0z24JduYHx5tm5FtaVYGr7jvVHX0YaEX0OAPvObvxXvwWCGvA iO43Xk9oHPH9BzeSDRUXaDq+mt4rn8Pk+eLBoe67IXDYYPzyv1z11yoNsKowCbXg== Received: by recvd-65bb6cdcb5-l7dpj with SMTP id recvd-65bb6cdcb5-l7dpj-1-682422C8-7 2025-05-14 04:57:44.53346032 +0000 UTC m=+3048541.752768211 Received: from herokuapp.com (unknown) by geopod-ismtpd-3 (SG) with ESMTP id VKCy-dBVQ8W53pnyOLhUog for ; Wed, 14 May 2025 04:57:44.521 +0000 (UTC) Date: Wed, 14 May 2025 04:57:44 +0000 (UTC) Message-ID: References: Mime-Version: 1.0 X-Redmine-Project: ruby-master X-Redmine-Issue-Tracker: Bug X-Redmine-Issue-Id: 21337 X-Redmine-Issue-Author: koic X-Redmine-Issue-Priority: Normal X-Redmine-Sender: koic 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: 98842 X-SG-EID: =?us-ascii?Q?u001=2EpOR99jQN1eojChpgtpUyjIxewEYD7=2FZx7LLvEjQQnJ8cwbBZnXJIEN6Qc?= =?us-ascii?Q?Bu1GTUUa4X7dr1C+34Vt4YdaVahPUbJNpAYDYXG?= =?us-ascii?Q?szY3Mbzf96hYvblCTM4PBHccyGre6xQZ7gcAqbi?= =?us-ascii?Q?aS9vTf837DF0Tr6yfaqS7TLDgLRPL6xbVW2wdVA?= =?us-ascii?Q?2C4+oGwulTctF0pzzpqJ+uMCmM0jKUZQJViYAOG?= =?us-ascii?Q?TaqmUpgEmrr7ZNcNveXX5CbYko6YV0dk3WlXKpj?= =?us-ascii?Q?EPwC?= To: ruby-core@ml.ruby-lang.org X-Entity-ID: u001.I8uzylDtAfgbeCOeLBYDww== Message-ID-Hash: QOH4AX5PLW5J5TU7JI6OKU4AUNINY7CB X-Message-ID-Hash: QOH4AX5PLW5J5TU7JI6OKU4AUNINY7CB 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:122086] [Ruby Bug#21337] Using `not` on the RHS of a logical operator becomes valid syntax with Prism List-Id: Ruby developers Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: "koic (Koichi ITO) via ruby-core" Cc: "koic (Koichi ITO)" Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Issue #21337 has been reported by koic (Koichi ITO). ---------------------------------------- Bug #21337: Using `not` on the RHS of a logical operator becomes valid syntax with Prism https://bugs.ruby-lang.org/issues/21337 * Author: koic (Koichi ITO) * Status: Open * ruby -v: ruby 3.4.3 (2025-04-14 revision d0b7e5b6a0) +PRISM [x86_64-darwin24] * Backport: 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN ---------------------------------------- The following syntax behavior differs between Ruby 3.3 (parse.y by default) and Ruby 3.4 (Prism by default). ```ruby if true && not true; end ``` ## Expected In Ruby 3.3 and earlier, the following code results in a syntax error. The default parser is `parse.y`. ```console $ ruby -vce 'if true && not true; end' ruby 3.3.8 (2025-04-09 revision b200bad6cd) [x86_64-darwin24] -e:1: syntax error, unexpected `true', expecting '(' if true && not true; end ruby: compile error (SyntaxError) ``` The key point is that `not` is used on the right-hand side of a logical operator. ## Actual When the default parser is switched to Prism, it is accepted as valid syntax with Ruby 3.4+ (Prism by default): ```console $ ruby -vce 'if true && not true; end' ruby 3.4.3 (2025-04-14 revision d0b7e5b6a0) +PRISM [x86_64-darwin24] Syntax OK $ ruby -vce 'if true && not true; end' ruby 3.5.0dev (2025-05-13T02:05:19Z master 9b8c846bdf) +PRISM [x86_64-darwin24] Syntax OK ``` Specifying parse.y causes a syntax error, as before 3.3 (parse.y by default): ```console $ ruby -vce 'if true && not true; end' ruby 3.3.8 (2025-04-09 revision b200bad6cd) [x86_64-darwin24] -e:1: syntax error, unexpected `true', expecting '(' if true && not true; end ruby: compile error (SyntaxError) $ ruby --parser=parse.y -vce 'if true && not true; end' ruby 3.5.0dev (2025-05-13T02:05:19Z master 9b8c846bdf) [x86_64-darwin24] -e:1: syntax error, unexpected 'true', expecting '(' if true && not true; end ruby: compile error (SyntaxError) ``` The behavior seen in the parse.y producing a syntax error might be probably the expected one. Any case, it is likely that users would not expect such a discrepancy between parsers. This issue was noticed in the context of the following RuboCop issue: https://github.com/rubocop/rubocop/issues/14177 -- 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/