From 2174f4a02939051c802f008f1f1dea2ace0e568c Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Thu, 15 Sep 2016 07:58:21 -0600 Subject: [PATCH] fix optimizer bug Closes #1461 Thanks to Gustavo for tracking down the problem. --- pkgs/racket-test-core/tests/racket/optimize.rktl | 12 +++++++++++- racket/src/racket/src/optimize.c | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/pkgs/racket-test-core/tests/racket/optimize.rktl b/pkgs/racket-test-core/tests/racket/optimize.rktl index 15e264b433..2f0f45a524 100644 --- a/pkgs/racket-test-core/tests/racket/optimize.rktl +++ b/pkgs/racket-test-core/tests/racket/optimize.rktl @@ -6228,7 +6228,17 @@ (write (compile e) o) (parameterize ([read-accept-compiled #t]) (eval (read (open-input-bytes (get-output-bytes o))))) - ((dynamic-require ''uses-mutator-with-an-auto-field 'f) #f)) + ((dynamic-require ''uses-mutator-with-an-auto-field 'f) #f)) + +;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; Make sure that the optimizer doesn't discard a known error on the +;; right-hand side of a `letrec` + +(err/rt-test + (letrec-values ([() (list (3) the-val)] + [(the-val) 42]) + 777) + exn:fail:contract?) ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; diff --git a/racket/src/racket/src/optimize.c b/racket/src/racket/src/optimize.c index fc88c42cd6..cb9c3ee514 100644 --- a/racket/src/racket/src/optimize.c +++ b/racket/src/racket/src/optimize.c @@ -7136,7 +7136,7 @@ static Scheme_Object *optimize_lets(Scheme_Object *form, Optimize_Info *info, in (values (if id e1 e2) ...) and then split the values call, since duplicating the id use and test is likely to pay off. */ if ((pre_body->count != 1) - && (found_escapes + && ((!is_rec && found_escapes) || (is_values_apply(value, pre_body->count, rhs_info, merge_skip_vars, 1) && ((!is_rec && no_mutable_bindings(pre_body)) /* If the right-hand side is omittable, then there are