From unknown Sun Jun 22 00:53:19 2025 X-Loop: help-debbugs@gnu.org Subject: bug#49305: Regression regarding #nil in syntax expansions in 3.0.7 Resent-From: Rob Browning Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Wed, 30 Jun 2021 23:49:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 49305 X-GNU-PR-Package: guile X-GNU-PR-Keywords: To: 49305@debbugs.gnu.org X-Debbugs-Original-To: bug-guile@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.162509692012872 (code B ref -1); Wed, 30 Jun 2021 23:49:02 +0000 Received: (at submit) by debbugs.gnu.org; 30 Jun 2021 23:48:40 +0000 Received: from localhost ([127.0.0.1]:59064 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lyjwe-0003LY-2r for submit@debbugs.gnu.org; Wed, 30 Jun 2021 19:48:40 -0400 Received: from lists.gnu.org ([209.51.188.17]:49002) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lyjwc-0003LQ-NZ for submit@debbugs.gnu.org; Wed, 30 Jun 2021 19:48:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47586) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lyjwa-0006R8-Pf for bug-guile@gnu.org; Wed, 30 Jun 2021 19:48:38 -0400 Received: from defaultvalue.org ([45.33.119.55]:44236) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lyjwZ-0005FQ-26 for bug-guile@gnu.org; Wed, 30 Jun 2021 19:48:36 -0400 Received: from trouble.defaultvalue.org (localhost [127.0.0.1]) (Authenticated sender: rlb@defaultvalue.org) by defaultvalue.org (Postfix) with ESMTPSA id 0E366200F3 for ; Wed, 30 Jun 2021 18:48:03 -0500 (CDT) Received: by trouble.defaultvalue.org (Postfix, from userid 1000) id 6087614E48D; Wed, 30 Jun 2021 18:48:02 -0500 (CDT) From: Rob Browning Date: Wed, 30 Jun 2021 18:48:02 -0500 Message-ID: <87eecididp.fsf@trouble.defaultvalue.org> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=45.33.119.55; envelope-from=rlb@defaultvalue.org; helo=defaultvalue.org X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.4 (-) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.4 (--) In 3.0.7, this: (define-syntax foo (syntax-rules () ((_ x) (eq? #nil x)))) (foo #t) began crashing like this: ice-9/psyntax.scm:2795:12: In procedure syntax-violation: Syntax error: unknown location: unexpected syntax in form () git bisect suggested the source of the trouble might be this change: commit 0cc799185576712d69f11fc794454f2f5447bef7 Date: Thu Feb 25 09:33:15 2021 +0100 Ensure that (syntax ()) results in () * module/ice-9/psyntax.scm: Add a special case for (). There are already special cases for pairs, vectors, etc; the issue is that with read-syntax, the () might be come into psyntax as an annotated syntax object, which here we would want to strip, to preserve the invariant to psyntax users that all lists are unwrapped. And this change to the same code appears to fix the problem, while still passing all the existing tests (the assumption being that we might need to special case #nil too): diff --git a/module/ice-9/psyntax.scm b/module/ice-9/psyntax.scm index 663d9275a..bd4bd6723 100644 --- a/module/ice-9/psyntax.scm +++ b/module/ice-9/psyntax.scm @@ -2157,6 +2157,7 @@ (lambda () (gen-syntax src #'(e1 e2 ...) r maps ellipsis? mod)) (lambda (e maps) (values (gen-vector e) maps)))) + (x (eq? (syntax->datum #'x) #nil) (values '(quote #nil) maps)) (() (values '(quote ()) maps)) (_ (values `(quote ,e) maps)))))) diff --git a/test-suite/tests/syntax.test b/test-suite/tests/syntax.test index a2999ac43..510e7104d 100644 --- a/test-suite/tests/syntax.test +++ b/test-suite/tests/syntax.test @@ -1684,6 +1684,16 @@ (hash interpreted most-positive-fixnum) (hash compiled most-positive-fixnum)))) +(with-test-prefix "#nil in syntaxes" + (pass-if-equal "does not crash" + 42 + (let () + (define-syntax foo + (syntax-rules () + ;; In 3.0.7 this would crash with + ;; unknown location: unexpected syntax in form () + ((_ x) (when (eq? x #nil) 42)))) + (foo #nil)))) ;;; Local Variables: ;;; eval: (put 'pass-if-syntax-error 'scheme-indent-function 1) So I wondered whether this might be a plausible fix. (I originally noticed because it breaks lokke, which like the elisp dialect, depends more heavily on #nil.) Thanks -- Rob Browning rlb @defaultvalue.org and @debian.org GPG as of 2011-07-10 E6A9 DA3C C9FD 1FF8 C676 D2C4 C0F0 39E9 ED1B 597A GPG as of 2002-11-03 14DD 432F AE39 534D B592 F9A0 25C8 D377 8C7E 73A4 From unknown Sun Jun 22 00:53:19 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Rob Browning Subject: bug#49305: closed (Re: bug#49305: Regression regarding #nil in syntax expansions in 3.0.7) Message-ID: References: <877c6z9948.fsf@trouble.defaultvalue.org> <87eecididp.fsf@trouble.defaultvalue.org> X-Gnu-PR-Message: they-closed 49305 X-Gnu-PR-Package: guile Reply-To: 49305@debbugs.gnu.org Date: Sun, 12 Jan 2025 18:32:01 +0000 Content-Type: multipart/mixed; boundary="----------=_1736706721-28375-1" This is a multi-part message in MIME format... ------------=_1736706721-28375-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #49305: Regression regarding #nil in syntax expansions in 3.0.7 which was filed against the guile package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 49305@debbugs.gnu.org. --=20 49305: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D49305 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1736706721-28375-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 49305-done) by debbugs.gnu.org; 12 Jan 2025 18:31:54 +0000 Received: from localhost ([127.0.0.1]:49069 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tX2kb-0007NA-Oh for submit@debbugs.gnu.org; Sun, 12 Jan 2025 13:31:53 -0500 Received: from defaultvalue.org ([45.33.119.55]:41648) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tX2ka-0007N1-2K for 49305-done@debbugs.gnu.org; Sun, 12 Jan 2025 13:31:52 -0500 Received: from trouble.defaultvalue.org (localhost [127.0.0.1]) (Authenticated sender: rlb@defaultvalue.org) by defaultvalue.org (Postfix) with ESMTPSA id CAE19200CC for <49305-done@debbugs.gnu.org>; Sun, 12 Jan 2025 12:31:51 -0600 (CST) Received: by trouble.defaultvalue.org (Postfix, from userid 1000) id 725F614E066; Sun, 12 Jan 2025 12:31:51 -0600 (CST) From: Rob Browning To: 49305-done@debbugs.gnu.org Subject: Re: bug#49305: Regression regarding #nil in syntax expansions in 3.0.7 In-Reply-To: <87eecididp.fsf@trouble.defaultvalue.org> (Rob Browning's message of "Wed, 30 Jun 2021 18:48:02 -0500") References: <87eecididp.fsf@trouble.defaultvalue.org> Date: Sun, 12 Jan 2025 12:31:51 -0600 Message-ID: <877c6z9948.fsf@trouble.defaultvalue.org> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 49305-done X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Rob Browning writes: > In 3.0.7, this: > > (define-syntax foo > (syntax-rules () > ((_ x) (eq? #nil x)))) > > (foo #t) > > began crashing like this: > > ice-9/psyntax.scm:2795:12: In procedure syntax-violation: > Syntax error: > unknown location: unexpected syntax in form () I believe this has been fixed. Thanks -- Rob Browning rlb @defaultvalue.org and @debian.org GPG as of 2011-07-10 E6A9 DA3C C9FD 1FF8 C676 D2C4 C0F0 39E9 ED1B 597A GPG as of 2002-11-03 14DD 432F AE39 534D B592 F9A0 25C8 D377 8C7E 73A4 ------------=_1736706721-28375-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 30 Jun 2021 23:48:40 +0000 Received: from localhost ([127.0.0.1]:59064 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lyjwe-0003LY-2r for submit@debbugs.gnu.org; Wed, 30 Jun 2021 19:48:40 -0400 Received: from lists.gnu.org ([209.51.188.17]:49002) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lyjwc-0003LQ-NZ for submit@debbugs.gnu.org; Wed, 30 Jun 2021 19:48:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47586) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lyjwa-0006R8-Pf for bug-guile@gnu.org; Wed, 30 Jun 2021 19:48:38 -0400 Received: from defaultvalue.org ([45.33.119.55]:44236) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lyjwZ-0005FQ-26 for bug-guile@gnu.org; Wed, 30 Jun 2021 19:48:36 -0400 Received: from trouble.defaultvalue.org (localhost [127.0.0.1]) (Authenticated sender: rlb@defaultvalue.org) by defaultvalue.org (Postfix) with ESMTPSA id 0E366200F3 for ; Wed, 30 Jun 2021 18:48:03 -0500 (CDT) Received: by trouble.defaultvalue.org (Postfix, from userid 1000) id 6087614E48D; Wed, 30 Jun 2021 18:48:02 -0500 (CDT) From: Rob Browning To: bug-guile@gnu.org Subject: Regression regarding #nil in syntax expansions in 3.0.7 Date: Wed, 30 Jun 2021 18:48:02 -0500 Message-ID: <87eecididp.fsf@trouble.defaultvalue.org> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=45.33.119.55; envelope-from=rlb@defaultvalue.org; helo=defaultvalue.org X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.4 (-) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.4 (--) In 3.0.7, this: (define-syntax foo (syntax-rules () ((_ x) (eq? #nil x)))) (foo #t) began crashing like this: ice-9/psyntax.scm:2795:12: In procedure syntax-violation: Syntax error: unknown location: unexpected syntax in form () git bisect suggested the source of the trouble might be this change: commit 0cc799185576712d69f11fc794454f2f5447bef7 Date: Thu Feb 25 09:33:15 2021 +0100 Ensure that (syntax ()) results in () * module/ice-9/psyntax.scm: Add a special case for (). There are already special cases for pairs, vectors, etc; the issue is that with read-syntax, the () might be come into psyntax as an annotated syntax object, which here we would want to strip, to preserve the invariant to psyntax users that all lists are unwrapped. And this change to the same code appears to fix the problem, while still passing all the existing tests (the assumption being that we might need to special case #nil too): diff --git a/module/ice-9/psyntax.scm b/module/ice-9/psyntax.scm index 663d9275a..bd4bd6723 100644 --- a/module/ice-9/psyntax.scm +++ b/module/ice-9/psyntax.scm @@ -2157,6 +2157,7 @@ (lambda () (gen-syntax src #'(e1 e2 ...) r maps ellipsis? mod)) (lambda (e maps) (values (gen-vector e) maps)))) + (x (eq? (syntax->datum #'x) #nil) (values '(quote #nil) maps)) (() (values '(quote ()) maps)) (_ (values `(quote ,e) maps)))))) diff --git a/test-suite/tests/syntax.test b/test-suite/tests/syntax.test index a2999ac43..510e7104d 100644 --- a/test-suite/tests/syntax.test +++ b/test-suite/tests/syntax.test @@ -1684,6 +1684,16 @@ (hash interpreted most-positive-fixnum) (hash compiled most-positive-fixnum)))) +(with-test-prefix "#nil in syntaxes" + (pass-if-equal "does not crash" + 42 + (let () + (define-syntax foo + (syntax-rules () + ;; In 3.0.7 this would crash with + ;; unknown location: unexpected syntax in form () + ((_ x) (when (eq? x #nil) 42)))) + (foo #nil)))) ;;; Local Variables: ;;; eval: (put 'pass-if-syntax-error 'scheme-indent-function 1) So I wondered whether this might be a plausible fix. (I originally noticed because it breaks lokke, which like the elisp dialect, depends more heavily on #nil.) Thanks -- Rob Browning rlb @defaultvalue.org and @debian.org GPG as of 2011-07-10 E6A9 DA3C C9FD 1FF8 C676 D2C4 C0F0 39E9 ED1B 597A GPG as of 2002-11-03 14DD 432F AE39 534D B592 F9A0 25C8 D377 8C7E 73A4 ------------=_1736706721-28375-1--