diff --git a/typed-racket-lib/typed-racket/optimizer/optimizer.rkt b/typed-racket-lib/typed-racket/optimizer/optimizer.rkt index 3c59d790..a9074eb5 100644 --- a/typed-racket-lib/typed-racket/optimizer/optimizer.rkt +++ b/typed-racket-lib/typed-racket/optimizer/optimizer.rkt @@ -24,9 +24,9 @@ (pattern opt:ignore-table^) ;; Can't optimize the body of this code because it isn't typechecked - (pattern (~and _:kw-lambda^ - ((~and op let-values) - ([(i:id) e-rhs:opt-expr]) e-body:expr ...)) + (pattern (~and (~or _:kw-lambda^ _:opt-lambda^) + ((~and op let-values) + ([(i:id) e-rhs:opt-expr]) e-body:expr ...)) #:with opt (quasisyntax/loc/origin this-syntax #'op (op ([(i) e-rhs.opt]) e-body ...))) diff --git a/typed-racket-test/optimizer/tests/opt-arg.rkt b/typed-racket-test/optimizer/tests/opt-arg.rkt new file mode 100644 index 00000000..8952c3b7 --- /dev/null +++ b/typed-racket-test/optimizer/tests/opt-arg.rkt @@ -0,0 +1,12 @@ +#lang typed/racket/base + +;; The optimizer now looks at all expressions regardless of shape (to log +;; all expressions with type (Vectorof Float) as candidates for uses of +;; flvectors). +;; This revealed that, previously, the optimizer did not skip the generated +;; body of optional arg function definitions (which is not typechecked, and so +;; should be skipped). It did for kw arg functions, but not optional. +;; This is now fixed, and this test is to guard against regressions. + +(define (slicef-at [force? #f]) + #f)