From: Nikodemus Siivola Date: Wed, 24 Aug 2011 11:49:09 +0000 (+0300) Subject: better errors for `(foo ,) X-Git-Url: http://repo.macrolet.net/gitweb/?a=commitdiff_plain;h=32c95570fd8253caca74ed16cde242b9ed3d08ab;p=sbcl.git better errors for `(foo ,) Report the trailing comma instead of an unmatched parenthesis. --- diff --git a/src/code/backq.lisp b/src/code/backq.lisp index 45a3ebd..fb9bd04 100644 --- a/src/code/backq.lisp +++ b/src/code/backq.lisp @@ -72,12 +72,21 @@ (simple-reader-error stream *bq-error*)) (let ((c (read-char stream)) (*backquote-count* (1- *backquote-count*))) - (cond ((char= c #\@) - (cons *bq-at-flag* (read stream t nil t))) - ((char= c #\.) - (cons *bq-dot-flag* (read stream t nil t))) - (t (unread-char c stream) - (cons *bq-comma-flag* (read stream t nil t)))))) + (flet ((check (what) + (let ((x (peek-char t stream t nil t))) + (when (and (char= x #\)) (eq #'read-right-paren (get-macro-character #\)))) + ;; Easier to figure out than an "unmatched parenthesis". + (simple-reader-error stream "Trailing ~A in backquoted expression." what))))) + (cond ((char= c #\@) + (check "comma-at") + (cons *bq-at-flag* (read stream t nil t))) + ((char= c #\.) + (check "comma-dot") + (cons *bq-dot-flag* (read stream t nil t))) + (t + (unread-char c stream) + (check "comma") + (cons *bq-comma-flag* (read stream t nil t))))))) (/show0 "backq.lisp 83")