fix with-syntax* when it has no patterns

This also fix define-inline for 0-arity functions.
This commit is contained in:
Gustavo Massaccesi 2019-02-10 23:38:57 -03:00
parent 3c4f160346
commit 5c1b1bf8cf
3 changed files with 9 additions and 3 deletions

View File

@ -5216,6 +5216,10 @@
(test #t equal? output
(bytes->string/utf-8 (get-output-bytes O #t)))))
;;
(define-inline (f0) (+ 1 0))
(test/output (f0)
1 "")
;;
(define-inline (f x) (+ x x))
(test/output (f (show 'arg1 1))
2 "arg1")

View File

@ -25,7 +25,7 @@
(lambda (x s-exp?)
(syntax-case x ()
((_ () e1 e2 ...)
(syntax/loc x (begin e1 e2 ...)))
(syntax/loc x (let () e1 e2 ...)))
((_ ((out in) ...) e1 e2 ...)
(let ([ins (syntax->list (syntax (in ...)))])
;; Check for duplicates or other syntax errors:

View File

@ -205,6 +205,8 @@
(define-syntax (with-syntax* stx)
(syntax-case stx ()
[(_ (cl) body ...) #'(with-syntax (cl) body ...)]
[(_ () body ...) (syntax/loc stx (let () body ...))]
[(_ (cl) body ...) (syntax/loc stx (with-syntax (cl) body ...))]
[(_ (cl cls ...) body ...)
#'(with-syntax (cl) (with-syntax* (cls ...) body ...))]))
(with-syntax ([with-syntax/rest (syntax/loc stx (with-syntax* (cls ...) body ...))])
(syntax/loc stx (with-syntax (cl) with-syntax/rest)))]))