Parse syntax-rules more strictly

See issue #767.
This commit is contained in:
Marc Nieper-Wißkirchen 2021-07-29 13:47:05 +02:00
parent 1f508fbdb5
commit 1f9b4796d6
2 changed files with 7 additions and 4 deletions

View file

@ -1105,7 +1105,11 @@
_or _or
(append (append
(map (map
(lambda (clause) (expand-pattern (car clause) (cadr clause))) (lambda (clause)
(if (and (list? clause) (= (length clause) 2))
(expand-pattern (car clause) (cadr clause))
(error "invalid syntax-rules clause, which must be of the form (pattern template) (note fenders are not supported)"
clause)))
forms) forms)
(list (list
(list _cons (list _cons

View file

@ -195,8 +195,7 @@
(syntax-rules () (syntax-rules ()
((define-c-int-type type) ((define-c-int-type type)
(if (not (memq 'type *c-int-types*)) (if (not (memq 'type *c-int-types*))
(set! *c-int-types* (cons 'type *c-int-types*))) (set! *c-int-types* (cons 'type *c-int-types*))))))
#f)))
(define-syntax define-c-enum (define-syntax define-c-enum
;; TODO: support conversion to/from symbolic names ;; TODO: support conversion to/from symbolic names
@ -640,7 +639,7 @@
(let ((e (x->string errno))) (let ((e (x->string errno)))
(string-append " case " e ": return \"" e "\";\n"))) (string-append " case " e ": return \"" e "\";\n")))
errnos) errnos)
" } " }
snprintf(buf, 64, \"unknown error: %d\", err); snprintf(buf, 64, \"unknown error: %d\", err);
return buf; return buf;