unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
From: Rob Browning <rlb@defaultvalue.org>
To: 49305@debbugs.gnu.org
Subject: bug#49305: Regression regarding #nil in syntax expansions in 3.0.7
Date: Wed, 30 Jun 2021 18:48:02 -0500	[thread overview]
Message-ID: <87eecididp.fsf@trouble.defaultvalue.org> (raw)


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





                 reply	other threads:[~2021-06-30 23:48 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87eecididp.fsf@trouble.defaultvalue.org \
    --to=rlb@defaultvalue.org \
    --cc=49305@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).