From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on starla X-Spam-Level: X-Spam-Status: No, score=-1.2 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 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=aYqw3knO; 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=qGLKvS7U; dkim-atps=neutral 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 0E6DB1F6CC for ; Mon, 15 Sep 2025 22:28:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ml.ruby-lang.org; s=mail; t=1757975302; bh=OITBskB6w2kan9qqcfjo9p/s86V3UBQOzwJZUUij4hg=; 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=aYqw3knO3AMU0FJ6TZikwJRCZgH382NqA0Fi7qfe7miHhDWcT61L0JSS2Eb55k8jc xHcQat6WWbSsZLMltQ8B7nwc13P7lJbVgDF3FqQmnX8P0wsuURUhoi/Wpo4MHeCVJG +SSVbuPX4wI3JbHnwc7sqn8OFMBcSv1ZTnKLKZ3A= Received: from nue.mailmanlists.eu (localhost [IPv6:::1]) by nue.mailmanlists.eu (Postfix) with ESMTP id CED6548F89 for ; Mon, 15 Sep 2025 22:28:22 +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=qGLKvS7U; dkim-atps=neutral Received: from s.wrqvtzvf.outbound-mail.sendgrid.net (s.wrqvtzvf.outbound-mail.sendgrid.net [149.72.126.143]) by nue.mailmanlists.eu (Postfix) with ESMTPS id 27D0D42D82 for ; Mon, 15 Sep 2025 22:27:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ruby-lang.org; h=date:from:references:subject:mime-version:content-type: content-transfer-encoding:list-id:to:cc:content-type:date:from:subject:to; s=s1; bh=w7/I+wlVW7orcTEoODuG4PzQImTvrirhU9JaCVeRxdo=; b=qGLKvS7UCNARfyd+enFFjROFPYIC8swvXLUKB9F4iVBaQPzxnsc69r1SVusooVAOLAq5 M0SSfFW5g/2cDU0V8B3Xl9lv1fY4OngrW1IeYsMqPBHf4kl8ST75u73Mvo8ERA1Wr/2v3v acBSLM7qzNBjuDQJggteQEC+gBIYNzT4DTiSiFrxeF9a5+YrMxICenOSnr4LjypNvF+gei Fq07ppU6GIWtjjaw/EKBNoAaNVe/xSGUdjxEfQ6ZjxhjUGkhmXsxUNAPPdb6J6dtIiDi6g U4GLsNttnAa/vP8I+UsRby/oZOWcEbzeBXMFDUs/8ROiLhCDe0j04Tpi39y9DWaw== Received: by recvd-769f975875-gf4q7 with SMTP id recvd-769f975875-gf4q7-1-68C892C5-C 2025-09-15 22:27:17.680368164 +0000 UTC m=+1121006.981980038 Received: from herokuapp.com (unknown) by geopod-ismtpd-18 (SG) with ESMTP id 8ZSSnbHWStOj34BlpDQ-pg for ; Mon, 15 Sep 2025 22:27:17.652 +0000 (UTC) Date: Mon, 15 Sep 2025 22:27:17 +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-Assignee: Group (prism) X-Redmine-Issue-Priority: Normal X-Redmine-Sender: k0kubun 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: 100084 X-SG-EID: =?us-ascii?Q?u001=2EsWSpkbcla4bB6tSlkOwdN01=2FLLwMflJlYDs0Ak3Gg6dwg4YUERnU2ZQsI?= =?us-ascii?Q?KPesnHmuO3R4nEnLV41FQje7rMJs=2FlByQKQxPtJ?= =?us-ascii?Q?4AIt7Pq58gCJ5UxQ0wAQ5dfBtfCGmi=2FkHMnlH8W?= =?us-ascii?Q?jBqY1aU2oRhcoxVEId3LH9gnm0B+2Lx+exhQHMM?= =?us-ascii?Q?EeR4vwBgF=2FE3Q=2FFvyoSsehzFji=2Fzx0UrXW5bH2p?= =?us-ascii?Q?hfu0Z0115avx4BSCzT0lqnAvNxnP=2F9gCrDZJEK1?= =?us-ascii?Q?MXhO+FBmAvd4316ixae1S3eTYA=3D=3D?= To: ruby-core@ml.ruby-lang.org X-Entity-ID: u001.I8uzylDtAfgbeCOeLBYDww== Message-ID-Hash: WA3S3DQ7LDMQBONDWARYGOO4Q4RXGPPI X-Message-ID-Hash: WA3S3DQ7LDMQBONDWARYGOO4Q4RXGPPI X-MailFrom: bounces+313651-b711-ruby-core=ml.ruby-lang.org@em5188.ruby-lang.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list Reply-To: Ruby developers Subject: [ruby-core:123255] [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: "k0kubun (Takashi Kokubun) via ruby-core" Cc: "k0kubun (Takashi Kokubun)" Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Issue #21337 has been updated by k0kubun (Takashi Kokubun). Backport changed from 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: REQUIRED to 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: DONE ruby_3_4 commit:52b3f006cb31672c45b26f6a44a609fd1b8e2ee5. ---------------------------------------- Bug #21337: Using `not` on the RHS of a logical operator becomes valid syntax with Prism https://bugs.ruby-lang.org/issues/21337#change-114619 * Author: koic (Koichi ITO) * Status: Closed * Assignee: prism * ruby -v: ruby 3.4.3 (2025-04-14 revision d0b7e5b6a0) +PRISM [x86_64-darwin24] * Backport: 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: DONE ---------------------------------------- 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/