Skip to content

Commit 2de1bdd

Browse files
committed
fix oc lowering with return type annotations
fixes #44723
1 parent e0c5e96 commit 2de1bdd

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/julia-syntax.scm

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4119,7 +4119,7 @@ f(x) = yt(x)
41194119
(cons (car e)
41204120
(map-cl-convert (cdr e) fname lam namemap defined toplevel interp opaq globals))))))))
41214121

4122-
(define (closure-convert e) (cl-convert e #f #f #f #f #f #f #f))
4122+
(define (closure-convert e) (cl-convert e #f #f (table) (table) #f #f #f))
41234123

41244124
;; pass 5: convert to linear IR
41254125

@@ -4403,7 +4403,10 @@ f(x) = yt(x)
44034403
(else
44044404
(compile-args (cdr e) break-labels))))
44054405
(callex (cons (car e) args)))
4406-
(cond (tail (emit-return callex))
4406+
(cond (tail (let ((tmp (make-ssavalue)))
4407+
;; can't just do (emit-return callex), since we might linearize code twice
4408+
(emit `(= ,tmp ,callex))
4409+
(emit-return tmp)))
44074410
(value callex)
44084411
(else (emit callex)))))
44094412
((=)

test/syntax.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3276,3 +3276,7 @@ end
32763276
@test m.Foo.bar === 1
32773277
@test Core.get_binding_type(m.Foo, :bar) == Any
32783278
end
3279+
3280+
# issue 44723
3281+
demo44723(thunk)::Any = Base.Experimental.@opaque () -> true ? 1 : 2
3282+
@test demo44723(7)() == 1

0 commit comments

Comments
 (0)