nanopass/nanopass-framework-racket

Can't using unquote-splicing in define-pass

Yoxem opened this issue · 2 comments

Yoxem commented

When make a pass that output a L0 type to type-checking, it can't use unquote-splicing but shows "unsaved editor:44:11: unquote-splicing: invalid pattern or template in: (unquote-splicing t*)
#(675 4)". (in DrRacket ver. 6.11). The code is shown below:

 #lang racket
 
 (require nanopass/base)
 
 (define (variable? x)
  (symbol? x))
 
 (define (constant? x)
  (or
   (flonum? x)
   (integer? x)
   (boolean? x)))
 
 (define (datatype? x)
   (memq x '(int flo bool void)))
  
 (define-language L0
   (terminals
     (variable (x))
     (datatype (dt))
     (constant (c)))
  
  
    (Expr (e body)
     x
     c
     (lambda ([t* x*] ... ) e))
   (Type (t)
     dt
     (-> t* ... t)
   )
   )
  (define-pass type-inference : L0 (ast) -> (L0 Type) ()
  
  (type-infer : Expr (e) -> Type ()
     ; constant
   [,c (cond
           [(flonum? e) 'flo]
           [(integer? e) 'int]
           [(boolean? e) 'bool])]
 
    [,x 'int]
     [(lambda ([,t* ,x*] ... ) ,body)
      `(-> ,@t* int) ;FIXIT: unquote-splicing: invalid pattern or template in: (unquote-splicing t*)
     ]
     )
      (type-infer ast)
 
  )
 (type-inference l0)

However, when set the output to a general s-expression (L0 Type) -> * (), and Type () -> * () , the error will not be shown.

akeep commented
Yoxem commented

I was also told by a Racket user (@dannypsnl) that the syntax (that @akeep mentioned above) ,t* … instead of ,@t* is that I want and I've found that it is true. I think that the issue can be closed. Thank you very much.