[Git][cmucl/cmucl][master] 2 commits: Fix #417: Allow repeated lambda var in defmethod aux variables

Raymond Toy pushed to branch master at cmucl / cmucl Commits: 6dba253c by Raymond Toy at 2025-06-30T08:36:53-07:00 Fix #417: Allow repeated lambda var in defmethod aux variables - - - - - 4e2e7fec by Raymond Toy at 2025-06-30T08:36:53-07:00 Merge branch 'issue-417-defmethod-check-aux-vars' into 'master' Fix #417: Allow repeated lambda var in defmethod aux variables Closes #417 See merge request cmucl/cmucl!306 - - - - - 2 changed files: - src/pcl/low.lisp - tests/pcl/defmethod.lisp Changes: ===================================== src/pcl/low.lisp ===================================== @@ -357,15 +357,20 @@ the compiler as completely as possible. Currently this means that (when morep (simple-program-error "~@<~s not allowed here~@:>" 'c:&more)) (collect ((vars)) - (labels ((check-var (var) - (cond ((not (symbolp var)) - (simple-program-error - "~@<Invalid lambda variable: ~s~@:>" var)) - ((memq var (vars)) - (simple-program-error - "~@<Repeated lambda variable: ~s~@:>" var)) - (t - (vars var)))) + (labels ((check-lambda-variable (var) + (unless (symbolp var) + (simple-program-error + "~@<Invalid lambda variable: ~s~@:>" var))) + (check-var (var) + (check-lambda-variable var) + (if (memq var (vars)) + (simple-program-error + "~@<Repeated lambda variable: ~s~@:>" var) + (vars var))) + (check-aux (var) + (if (consp var) + (check-lambda-variable (car var)) + (check-lambda-variable var))) (check-required (var) (if (and (consp var) specialized-p) (check-var (car var)) @@ -385,7 +390,7 @@ the compiler as completely as possible. Currently this means that (mapc #'check-optional optional) (mapc #'check-optional keys) (when restp (check-var rest)) - (mapc #'check-optional aux) + (mapc #'check-aux aux) (values required optional restp rest keyp keys allow-other-keys-p aux))))) ===================================== tests/pcl/defmethod.lisp ===================================== @@ -74,7 +74,10 @@ (define-defmethod-test-1 defmethod.20 dm2 nil (x)) (define-defmethod-test-1 defmethod.21 dm2 nil (x &optional y z)) (define-defmethod-test-1 defmethod.22 dm2 nil (x &key y)) - +(define-defmethod-test-1 defmethod.23 dm2 nil (x y &aux (x x) (y y))) +(define-defmethod-test-1 defmethod.23 dm2 nil (x y &aux z)) +(define-defmethod-test-1 defmethod.23 dm2 nil (x y &aux z z)) +(define-defmethod-test-1 defmethod.23 dm2 nil (x y &aux z (z z))) ;;; ;;; A forward-referenced class used as specializer signaled an ;;; error at some point. View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/compare/32b155380ff18245c64664f... -- View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/compare/32b155380ff18245c64664f... You're receiving this email because of your account on gitlab.common-lisp.net.
participants (1)
-
Raymond Toy (@rtoy)