From 69e8fc6fcb0cd9e5669cc5332012c6ffbb4b61a5 Mon Sep 17 00:00:00 2001 From: Jeff Bezanson Date: Tue, 25 Sep 2018 17:40:45 -0400 Subject: [PATCH] fix #29326, return type lowering interfering with closure optimization (#29346) (cherry picked from commit 48f5bb3da5974a7c41903522d15179fe45da0a22) --- src/julia-syntax.scm | 20 +++++--------------- test/compiler/compiler.jl | 9 +++++++++ 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/src/julia-syntax.scm b/src/julia-syntax.scm index be21b395c0338..9e846bb181f3d 100644 --- a/src/julia-syntax.scm +++ b/src/julia-syntax.scm @@ -160,21 +160,11 @@ (let ((meta (take-while (lambda (x) (and (pair? x) (memq (car x) '(line meta)))) (cdr body))) - (val (last body))) - ;; wrap one-liners in `convert` instead of adding an ssavalue - (if (and (length= (cdr body) (+ 1 (length meta))) - (not (expr-contains-p return? (if (return? val) - (cadr val) - val)))) - `(,(car body) ,@meta - ,(if (return? val) - `(return ,(convert-for-type-decl (cadr val) rett)) - (convert-for-type-decl val rett))) - (let ((R (make-ssavalue))) - `(,(car body) ,@meta - (= ,R ,rett) - (meta ret-type ,R) - ,@(list-tail body (+ 1 (length meta)))))))))))) + (R (make-ssavalue))) + `(,(car body) ,@meta + (= ,R ,rett) + (meta ret-type ,R) + ,@(list-tail body (+ 1 (length meta)))))))))) ;; convert x<:T<:y etc. exprs into (name lower-bound upper-bound) ;; a bound is #f if not specified diff --git a/test/compiler/compiler.jl b/test/compiler/compiler.jl index 008b05d1de56c..9fe054dadfb83 100644 --- a/test/compiler/compiler.jl +++ b/test/compiler/compiler.jl @@ -1741,6 +1741,15 @@ function f15276(x) end @test Base.return_types(f15276(1), (Int,)) == [Int] +# issue #29326 +function f29326()::Any + begin + a = 1 + (() -> a)() + end +end +@test Base.return_types(f29326, ()) == [Int] + function g15276() spp = Int[0] sol = [spp[i] for i=1:0]