refuse a comparison of other than two operands
(< a b c) reached C as C's own chain, which compares a boolean with c.
This commit is contained in:
@@ -292,7 +292,17 @@ forms, and what remains."
|
||||
(('default . body) (cons 'default (walk-case-body body)))
|
||||
|
||||
;; Drop comments so they will not generate additional comma
|
||||
(else (map walk-expr (remove comment-form? form)))))
|
||||
(else
|
||||
(check-arity form)
|
||||
(map walk-expr (remove comment-form? form)))))
|
||||
|
||||
;;; Operands past what an operator takes were written as they came:
|
||||
;;; (< a b c) as C's own chain, which compares a boolean with c
|
||||
(define (check-arity form)
|
||||
(when (and (memq (car form) '(< > <= >= == !=))
|
||||
(not (= (count (lambda (part) (not (comment-form? part))) (cdr form)) 2)))
|
||||
(sex-error form "a comparison takes two operands; chain them with &&"
|
||||
(car form))))
|
||||
|
||||
;;; #(a b c) is a brace initializer. A `:' inside one ends a type and
|
||||
;;; turns the whole thing into a C99 compound literal:
|
||||
|
||||
Reference in New Issue
Block a user