diff --git a/typed-racket-lib/typed-racket/optimizer/unboxed-let.rkt b/typed-racket-lib/typed-racket/optimizer/unboxed-let.rkt index 88f2775d..3663cd74 100644 --- a/typed-racket-lib/typed-racket/optimizer/unboxed-let.rkt +++ b/typed-racket-lib/typed-racket/optimizer/unboxed-let.rkt @@ -188,6 +188,9 @@ (define (rec exp) (syntax-parse exp + ;; if there are unreachable expressions in the body, we can't check + ;; if it's worth unboxing, so just give up + [_:ignore-table^ #f] ;; can be used in a complex arithmetic expr, can be a direct child [(~and (~not :id) exp:float-complex-arith-expr) (or (direct-child-of? v #'exp) diff --git a/typed-racket-lib/typed-racket/typecheck/tc-let-unit.rkt b/typed-racket-lib/typed-racket/typecheck/tc-let-unit.rkt index 801e96ee..aebf1754 100644 --- a/typed-racket-lib/typed-racket/typecheck/tc-let-unit.rkt +++ b/typed-racket-lib/typed-racket/typecheck/tc-let-unit.rkt @@ -1,7 +1,8 @@ #lang racket/unit (require "../utils/utils.rkt" - (except-in (types utils abbrev filter-ops remove-intersect) -> ->* one-of/c) + (except-in (types utils abbrev filter-ops remove-intersect type-table) + -> ->* one-of/c) (only-in (types abbrev) (-> t:->) [->* t:->*]) (private type-annotation parse-type syntax-properties) (env lexical-env type-alias-helper mvar-env @@ -85,6 +86,9 @@ (get-names+objects namess expected-results) (with-lexical-env/extend-props (apply append props) + ;; if a let rhs does not return, the body isn't checked + #:unreachable (for ([form (in-list (syntax->list body))]) + (register-ignored! form)) ;; type-check the rhs exprs (for ([expr (in-list exprs)] [results (in-list expected-results)]) (match results diff --git a/typed-racket-test/fail/gh-issue-165.rkt b/typed-racket-test/fail/gh-issue-165.rkt new file mode 100644 index 00000000..f2223860 --- /dev/null +++ b/typed-racket-test/fail/gh-issue-165.rkt @@ -0,0 +1,17 @@ +#; +(exn-pred #rx"match-define") +#lang typed/racket + +(struct a ([x : Integer])) +(struct b ([y : Integer])) + +;; test for original report +(: f (-> a Integer)) +(define (f arg) + (match-define (a (b y)) arg) + (+ 1 y)) + +;; simple test case +(let () + (match-define (? string? x) 3) + (+ 1 2))