bugKawa - Bugs: bug #18504, Cannot generate...

 
 

bug #18504: Cannot generate (define-simple-class) using syntax-case macros

Submitter:  Margus Freudenthal <margus>
Submitted:  Mon 11 Dec 2006 09:02:15 AM UTC
   
 
Category:  Code generation Severity:  3 - Normal
Item Group:  Compile-time exception Status:  Fixed
Privacy:  Public Assigned to:  bothner
Open/Closed:  Closed
* Mandatory Fields

Add a New Comment Rich Markup
   

Tue 12 Dec 2006 08:11:24 AM UTC, comment #4: 

I checked in the patch for 18105, which should also fix the second problem in the report.

Per Bothner <bothner>
Group administrator
Mon 11 Dec 2006 08:30:57 PM UTC, comment #3: 

I checked in the attached patch.
I also checkws in the testcase (see testing/obj-test.scm and testing/ChangeLog).  Thanks!

Do try to not mix different bugs in the same bug report.  (Admittedly sometimes it isn't obvious whether something is a different symptom of the same bug, so you have make a best guess.)

(file #11506)

Per Bothner <bothner>
Group administrator
Mon 11 Dec 2006 02:07:22 PM UTC, comment #2: 

Oops. The second problem is duplicate of https://savannah.gnu.org/bugs/index.php?18105

Margus Freudenthal <margus>
Mon 11 Dec 2006 02:04:57 PM UTC, comment #1: 

Additionally, the following macro works in REPL, but fails when compiling.

(define-syntax aa
  (lambda (x)
    (syntax-case x ()
      ((_ cl arg)
       (with-syntax
        ((param-name (datum->syntax-object
                      #`arg
                      (string->symbol
                       (string-append
                        "param-"
                        (symbol->string (syntax-object->datum #`arg)))))))
        #`(define-simple-class cl ()
            (param-name)))))))

(aa MyClass oioi)

java.lang.NullPointerException
        at gnu.expr.ReferenceExp.apply(ReferenceExp.java:142)
        at gnu.mapping.CallContext.runUntilDone(CallContext.java:251)
        at gnu.mapping.CallContext.getFromContext(CallContext.java:280)
        at gnu.expr.Expression.eval(Expression.java:24)
        at gnu.expr.ApplyExp.apply(ApplyExp.java:63)
        at gnu.mapping.CallContext.runUntilDone(CallContext.java:251)
        at gnu.mapping.CallContext.getFromContext(CallContext.java:280)
        at gnu.expr.Expression.eval(Expression.java:24)
        at gnu.expr.IfExp.apply(IfExp.java:33)
        at gnu.mapping.CallContext.runUntilDone(CallContext.java:251)
        at gnu.mapping.CallContext.getFromContext(CallContext.java:280)
        at gnu.expr.Expression.eval(Expression.java:24)
        at gnu.expr.BlockExp.apply(BlockExp.java:46)
        at gnu.expr.LetExp.apply(LetExp.java:64)
        at gnu.expr.LetExp.apply(LetExp.java:64)
        at gnu.expr.IfExp.apply(IfExp.java:34)
        at gnu.mapping.CallContext.runUntilDone(CallContext.java:251)
        at gnu.mapping.CallContext.getFromContext(CallContext.java:280)
        at gnu.expr.Expression.eval(Expression.java:24)
        at gnu.expr.BlockExp.apply(BlockExp.java:46)
        at gnu.expr.LetExp.apply(LetExp.java:64)
        at gnu.expr.Closure.apply(LambdaExp.java:1906)
        at gnu.mapping.CallContext.runUntilDone(CallContext.java:251)
        at gnu.mapping.CallContext.runUntilValue(CallContext.java:315)
        at gnu.mapping.MethodProc.applyN(MethodProc.java:105)
        at gnu.mapping.ProcedureN.apply1(ProcedureN.java:31)
        at kawa.lang.Macro.expand(Macro.java:178)
        at kawa.lang.Macro.scanForm(Macro.java:206)
        at kawa.lang.Translator.scanForm(Translator.java:959)
        at gnu.kawa.lispexpr.LispLanguage.parse(LispLanguage.java:69)
        at gnu.expr.Language.parse(Language.java:547)
        at gnu.expr.Language.parse(Language.java:523)
        at kawa.repl.compileFiles(repl.java:728)
        at kawa.repl.processArgs(repl.java:425)
        at kawa.repl.main(repl.java:827)
(compiling test-macro.scm)
test-macro.scm:24:1: evaluating syntax transformer 'aa' threw java.lang.NullPointerException

However, the following variant compiles OK:

(define-syntax aa
  (lambda (x)
    (syntax-case x ()
      ((_ cl arg)
       #`(define-simple-class cl ()
           (,(datum->syntax-object
              #`arg
              (string->symbol
               (string-append
                "param-"
                (symbol->string (syntax-object->datum #`arg)))))))))))

Margus Freudenthal <margus>
Mon 11 Dec 2006 09:02:15 AM UTC, original submission:  

When I try to generate class inside macro, I get exception.

Macro:

(define-syntax aa
  (lambda (x)
    (syntax-case x ()
      ((_ cl arg argtype)
       #`(define-simple-class cl ()
           (arg type: argtype))))))

#|kawa:7|# (aa MyClass myparam <String>)
<stdin>:7:1: invalid type spec (must be "type" or 'type or <type>)

When I use <String> instead of argtype, it compiles.

Margus Freudenthal <margus>

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #11506:  object-keywords.patch added by bothner (837B - text/x-patch - patch for original problem)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by bothner (Updated the item)
  • -email is unavailable- added by margus (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 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2006-12-12 bothner StatusIn Progress Fixed
        Open/ClosedOpen Closed
    2006-12-11 bothner Attached File- Added object-keywords.patch, #11506
        StatusNone In Progress
        Assigned toNone bothner
    2006-12-11 margus Carbon-Copy- Added -email is unavailable-

    Back to the top

    Powered by Savane 3.13-4b48.
    Corresponding source code