diff --git a/src/typechecker/define.lisp b/src/typechecker/define.lisp index e85bc7299..dc707f781 100644 --- a/src/typechecker/define.lisp +++ b/src/typechecker/define.lisp @@ -2272,8 +2272,14 @@ Returns (VALUES INFERRED-TYPE NODE SUBSTITUTIONS)") :span (parser:node-source second) :message "second parameter here")))))) - (let* ((param-tys (loop :for pattern :in (parser:binding-parameters binding) - :collect (tc:make-variable))) + (let* ((param-tys (loop :with args := (tc:function-type-arguments expected-type) + :for pattern :in (parser:binding-parameters binding) + + :if args + :collect (car args) + :and :do (setf args (cdr args)) + :else + :collect (tc:make-variable))) (params (loop :for pattern :in (parser:binding-parameters binding) :for ty :in param-tys diff --git a/tests/struct-tests.lisp b/tests/struct-tests.lisp index 9658f5c5b..97314a3b5 100644 --- a/tests/struct-tests.lisp +++ b/tests/struct-tests.lisp @@ -89,3 +89,14 @@ (define (f _) (let ((g (fn (p) (.x p)))) (g (Point 1 2))))"))) + +;; See gh #959 +(deftest test-accessor-on-argument-let-binding () + (check-coalton-types + "(define-struct (Wrapper :a) + (inner :a)) + + (declare f (Wrapper :a -> :a)) + (define (f x) + (let ((y (.inner x))) + y))"))