bugMIT/GNU Scheme - Bugs: bug #57793, bug in nested syntax-rules macro

 
 

bug #57793: bug in nested syntax-rules macro

Submitter:  Arthur A. Gleckler <aag>
Submitted:  Tue 11 Feb 2020 07:25:41 PM UTC
   
 
Category:  runtime Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect behavior
Status:  None Privacy:  Public
Assigned to:  cph Originator Name: 
Open/Closed:  Closed
Keywords: 
* Mandatory Fields

Add a New Comment Rich Markup
   

Sun 16 Feb 2020 07:15:58 PM UTC, comment #4: 

Okay, I've re-closed this bug after opening a new bug report (#57833) for the new bug the fix appears to have caused.

Arthur A. Gleckler <aag>
Group Member
Thu 13 Feb 2020 07:43:47 AM UTC, comment #3: 

letrec-syntax is now broken:


1 ]=> (define-syntax foo
  (syntax-rules ()
    ((_ xy)
     (letrec-syntax
         ((bar1 (syntax-rules ()
                  ((_ (else* destination))
                   (destination))))
          (bar2 (syntax-rules ()
                  ((_ z)
                   (bar1 z)))))
       (bar2 xy)))))

;Value: foo

1 ]=> (pp (lambda () (foo (else* start))))
(lambda ()
  (bar1 (else* start)))
;Unspecified return value

1 ]=>


Under 9.2.1 the answer was:


(lambda ()
  (start))


Arthur A. Gleckler <aag>
Group Member
Wed 12 Feb 2020 07:53:34 PM UTC, comment #2: 

Thanks, that fixed the bug.  Unfortunately, the same macro from which my example was distilled fails in a new way:


;Special keyword can't be expanded: (else end)


It looks like the keyword else is treated specially, so I can't use it in my macro any more.

I'll try to narrow that down.

Arthur A. Gleckler <aag>
Group Member
Wed 12 Feb 2020 07:21:02 AM UTC, comment #1: 

The first problem is an error, now fixed on HEAD.

The second problem is user error: the call to (bar y x) doesn't match the pattern.  The error message was confusing, now fixed on HEAD.

Chris Hanson <cph>
Group administrator
Tue 11 Feb 2020 07:25:41 PM UTC, original submission:  

At 9f175968f (10.90 today), this macro and its invocation:


(define-syntax foo
  (syntax-rules ()
    ((_ (x y z))
     (letrec-syntax
         ((bar (syntax-rules (q)
                 ((_ q w)
                  '()))))
       (bar y z)))))

(foo (x1 q z1))


cause this internal error:


;The object #[syntactic-closure 122 #[syntactic-closure 123 q]], passed as an argument to lookup-identifier, is not the correct type.


This macro isn't intended to do anything meaningful.  It's just a reproducible test case.  It's the distillation of a more elaborate macro that started resulting in the same error at 9f175968f, but worked before that.

Strangely, this variation:


(define-syntax foo
  (syntax-rules ()
    ((_ (x y z))
     (letrec-syntax
         ((bar (syntax-rules (q)
                 ((_ (q w))
                  '()))))
       (bar y z)))))

(foo (x1 q z1))


causes a different internal error:


;Ill-formed special form: #[uninterned-symbol 124 form]


The latter macro is buggy because there is no match in the inner macro, but the error that is reported is unhelpful.

Thanks for all your work tracking these down.

Arthur A. Gleckler <aag>
Group Member

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by cph (Posted a comment)
  • -email is unavailable- added by aag (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2020-02-16 aag Open/ClosedOpen Closed
    2020-02-14 aag StatusFixed None
    2020-02-12 cph StatusNone Fixed
        Assigned toNone cph
    2020-02-11 aag Summarysyntax-rules nesting broken bug in nested syntax-rules macro

    Back to the top

    Powered by Savane 3.13-02a9.
    Corresponding source code