Changeset 15378


Ignore:
Timestamp:
May 24, 2012, 10:14:26 AM (13 years ago)
Author:
Gary Byers
Message:

(Thought I'd checked this in a few weeks ago.)
If SETF is used on a structure accessor, error at macroexpand time
if the accessor is called with other than 1 arg. (If we don't
check here, the error that happens later is even more obscure and
has even less to do with user code.)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/lib/macros.lisp

    r15344 r15378  
    573573                      (if local-p
    574574                        (if (eq ftype :function)
    575                                         ;Local function, so don't use global setf definitions.
     575                          ;;Local function, so don't use global setf
     576                          ;;definitions.
    576577                          (default-setf form value env)
    577578                          `(setf ,(macroexpand-1 form env) ,value))
     
    596597                                (accessor-structref-info-p temp)
    597598                                (not (refinfo-r/o (structref-info-refinfo temp))))
     599                           (let* ((nargs (length (%cdar args))))
     600                             (unless (eql nargs 1)
     601                               (signal-simple-program-error
     602                                "In ~s, structure accessor ~s requires exactly 1 argument but is being called with ~d arguments." `(setf ,@args) accessor nargs)))
    598603                           (let ((form (defstruct-ref-transform temp (%cdar args) env t))
    599604                                 (type (defstruct-type-for-typecheck (structref-info-type temp) env)))
     
    602607                               ;; strip off type, but add in a typecheck
    603608                               `(the ,type (setf ,form (typecheck ,value ,type))))))
     609
    604610                          (t
    605611                           (multiple-value-bind (res win)
Note: See TracChangeset for help on using the changeset viewer.