From 2de1bdde45b9c85b450f990896a18ba93124b3a7 Mon Sep 17 00:00:00 2001 From: Simeon David Schaub Date: Thu, 24 Mar 2022 00:30:50 -0400 Subject: [PATCH] fix oc lowering with return type annotations fixes #44723 --- src/julia-syntax.scm | 7 +++++-- test/syntax.jl | 4 ++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/julia-syntax.scm b/src/julia-syntax.scm index 10c204e1c50a6d..669ae8648b8de3 100644 --- a/src/julia-syntax.scm +++ b/src/julia-syntax.scm @@ -4119,7 +4119,7 @@ f(x) = yt(x) (cons (car e) (map-cl-convert (cdr e) fname lam namemap defined toplevel interp opaq globals)))))))) -(define (closure-convert e) (cl-convert e #f #f #f #f #f #f #f)) +(define (closure-convert e) (cl-convert e #f #f (table) (table) #f #f #f)) ;; pass 5: convert to linear IR @@ -4403,7 +4403,10 @@ f(x) = yt(x) (else (compile-args (cdr e) break-labels)))) (callex (cons (car e) args))) - (cond (tail (emit-return callex)) + (cond (tail (let ((tmp (make-ssavalue))) + ;; can't just do (emit-return callex), since we might linearize code twice + (emit `(= ,tmp ,callex)) + (emit-return tmp))) (value callex) (else (emit callex))))) ((=) diff --git a/test/syntax.jl b/test/syntax.jl index 99e371b09dd5a5..afffbabdf09114 100644 --- a/test/syntax.jl +++ b/test/syntax.jl @@ -3276,3 +3276,7 @@ end @test m.Foo.bar === 1 @test Core.get_binding_type(m.Foo, :bar) == Any end + +# issue 44723 +demo44723(thunk)::Any = Base.Experimental.@opaque () -> true ? 1 : 2 +@test demo44723(7)() == 1