syntax-case bug

Bug #223362 reported by leppie
2
Affects Status Importance Assigned to Milestone
Ikarus Scheme
Fix Committed
High
Abdulaziz Ghuloum

Bug Description

Ikarus Scheme version 0.0.3+ (revision 1452, build 2008-04-20)
Copyright (c) 2006-2008 Abdulaziz Ghuloum

> (syntax-case '(lambda (x) x) (lambda) [(lambda (x) y) #'x])
Unhandled exception
 Condition components:
   1. &assertion
   2. &who: stx-mark*
   3. &message: "not a struct of required type"
   4. &irritants: (lambda #<stx rtd>)

> (syntax-case '(lambda (x) x) (lambda) [(lambda (x) y) 'x])
Unhandled exception
 Condition components:
   1. &assertion
   2. &who: stx-mark*
   3. &message: "not a struct of required type"
   4. &irritants: (lambda #<stx rtd>)

Petite Chez Scheme Version 7.4
Copyright (c) 1985-2007 Cadence Research Systems

> (syntax-case '(lambda (x) x) (lambda) [(lambda (x) y) #'x])
x
> (syntax-case '(lambda (x) x) (lambda) [(lambda (x) y) 'x])
x

Cheers

leppie

Related branches

Revision history for this message
Abdulaziz Ghuloum (aghuloum) wrote :

Definitely a bug. Will fix. Thanks.

Changed in ikarus:
assignee: nobody → aghuloum
importance: Undecided → High
status: New → Confirmed
Revision history for this message
Abdulaziz Ghuloum (aghuloum) wrote :

The bug is actually in (identifier? 'sym) returning #t instead of #f.

Revision history for this message
leppie (leppie) wrote :

Here it the simplest case:

(syntax-case 'f (f) [f f])

Revision history for this message
leppie (leppie) wrote :

Oops, make that:

(syntax-case 'f (f) [f 'f])

Revision history for this message
Abdulaziz Ghuloum (aghuloum) wrote :

Now I fixed it (in revision 1453) BUT the examples you cited do not match because the lambda symbol is not an identifier and so it cannot be free-identifier=? with the lambda identifier listed in the literals lists. So, now you get:

Ikarus Scheme version 0.0.3+ (revision 1453, build 2008-04-28)
Copyright (c) 2006-2008 Abdulaziz Ghuloum

> (syntax-case '(lambda (x) x) (lambda) [(lambda (x) y) #'x])
Unhandled exception
 Condition components:
   1. &message: "invalid syntax"
   2. &syntax:
       form: (lambda (x) x)
       subform: #f
> (syntax-case '(lambda (x) x) (lambda) [(lambda (x) y) #'x] [_ 'nop!])
nop!
>

Changed in ikarus:
status: Confirmed → Fix Committed
Revision history for this message
leppie (leppie) wrote :

So if I understand you correctly syntax-case cannot match the lambda (or any other symbols) unless the input is syntax?

Revision history for this message
Abdulaziz Ghuloum (aghuloum) wrote : Re: [Bug 223362] Re: syntax-case bug

On Apr 28, 2008, at 3:50 PM, leppie wrote:
> So if I understand you correctly syntax-case cannot match the
> lambda (or
> any other symbols) unless the input is syntax?

To match a symbol as a literal, you need a specific guard like:

 > (syntax-case '(lambda (x) foo) ()
     [(kwd (x) y) (eq? #'kwd 'lambda)
      (list #'x #'y)])
(x foo)

[which works in ikarus, chez, and larceny]

Aziz,,,

Changed in ikarus:
milestone: none → 0.0.4
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.