From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Rob Browning Newsgroups: gmane.lisp.guile.bugs Subject: bug#49305: 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 Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="17533"; mail-complaints-to="usenet@ciao.gmane.io" To: 49305@debbugs.gnu.org Original-X-From: bug-guile-bounces+guile-bugs=m.gmane-mx.org@gnu.org Thu Jul 01 01:49:14 2021 Return-path: Envelope-to: guile-bugs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lyjxA-0004MM-Lx for guile-bugs@m.gmane-mx.org; Thu, 01 Jul 2021 01:49:12 +0200 Original-Received: from localhost ([::1]:33300 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lyjx8-0006fL-Vs for guile-bugs@m.gmane-mx.org; Wed, 30 Jun 2021 19:49:11 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:47614) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lyjx0-0006eY-LV for bug-guile@gnu.org; Wed, 30 Jun 2021 19:49:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:47518) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lyjx0-0005Wb-Eh for bug-guile@gnu.org; Wed, 30 Jun 2021 19:49:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lyjx0-0003MI-7t for bug-guile@gnu.org; Wed, 30 Jun 2021 19:49:02 -0400 X-Loop: help-debbugs@gnu.org 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-Debbugs-Original-To: bug-guile@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.162509692012872 (code B ref -1); Wed, 30 Jun 2021 23:49:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 30 Jun 2021 23:48:40 +0000 Original-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 Original-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 Original-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 Original-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 Original-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) Original-Received: by trouble.defaultvalue.org (Postfix, from userid 1000) id 6087614E48D; Wed, 30 Jun 2021 18:48:02 -0500 (CDT) 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-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-guile@gnu.org List-Id: "Bug reports for GUILE, GNU's Ubiquitous Extension Language" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guile-bounces+guile-bugs=m.gmane-mx.org@gnu.org Original-Sender: "bug-guile" Xref: news.gmane.io gmane.lisp.guile.bugs:10130 Archived-At: 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