unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
* [bug #31472] Probable psyntax bug with multiple defininitions in the macro expansion
@ 2010-10-26 20:42 Andreas Rottmann
  2011-02-27 12:33 ` Andy Wingo
  0 siblings, 1 reply; 4+ messages in thread
From: Andreas Rottmann @ 2010-10-26 20:42 UTC (permalink / raw)
  To: Andreas Rottmann, bug-guile


URL:
  <http://savannah.gnu.org/bugs/?31472>

                 Summary: Probable psyntax bug with multiple defininitions in
the macro expansion
                 Project: Guile
            Submitted by: rottmann
            Submitted on: Tue 26 Oct 2010 10:42:27 PM CEST
                Category: None
                Severity: 3 - Normal
              Item Group: None
                  Status: None
                 Privacy: Public
             Assigned to: None
             Open/Closed: Open
         Discussion Lock: Any

    _______________________________________________________

Details:

Given the following library:

(library (unbound-bug)
  (export define-foo)
  (import (rnrs))

  (define-syntax define-foo
    (lambda (x)
      (syntax-case x ()
        ((_ name)
         (identifier? #'name)
         #'(begin
             (define t '#(1 2 3))
             (define (name) t)))))))


I get this (what I deem faulty) behavior:

scheme@(guile-user)> (import (unbound-bug))
scheme@(guile-user)> (define-foo bar)
scheme@(guile-user)> (bar)
<unnamed port>:2:1: In procedure module-lookup:
<unnamed port>:2:1: Unbound variable: t

Entering a new prompt.  Type `,bt' for a backtrace or `,q' to continue.
scheme@(guile-user) [1]> 

If one modifies the original macro slightly, it works as expected:

  (define-syntax define-foo
    (lambda (x)
      (syntax-case x ()
        ((_ name)
         (identifier? #'name)
         (with-syntax ((t (datum->syntax #'name 't)))
           #'(begin
               (define t '#(1 2 3))
               (define (name) t))))))))

scheme@(guile-user)> (define-foo bar)                                        
                 
scheme@(guile-user)> (bar)
$1 = #(1 2 3)

Also (with the original macro), this works:

scheme@(guile-user)> (let () (define-foo bar) (bar))                         
                 
$1 = #(1 2 3)





    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?31472>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-06-09 16:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-26 20:42 [bug #31472] Probable psyntax bug with multiple defininitions in the macro expansion Andreas Rottmann
2011-02-27 12:33 ` Andy Wingo
2011-05-21 13:46   ` Göran Weinholt
2011-06-09 16:48     ` Stefan Israelsson Tampe

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).