Skip to content

Commit

Permalink
fix #29326, return type lowering interfering with closure optimization (
Browse files Browse the repository at this point in the history
#29346)

(cherry picked from commit 48f5bb3)
  • Loading branch information
JeffBezanson authored and KristofferC committed Feb 11, 2019
1 parent 50fc30d commit 7432bf8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
20 changes: 5 additions & 15 deletions src/julia-syntax.scm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions test/compiler/compiler.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit 7432bf8

Please sign in to comment.