Skip to content

Commit a72fc56

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

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

src/julia-syntax.scm

+10-8
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

@@ -4220,16 +4220,18 @@ f(x) = yt(x)
42204220
`(pop_exception ,restore-token))))
42214221
(define (emit-return x)
42224222
(define (actually-return x)
4223-
(let* ((x (if rett
4224-
(compile (convert-for-type-decl x rett) '() #t #f)
4225-
x))
4226-
(tmp (if ((if (null? catch-token-stack) valid-ir-return? simple-atom?) x)
4223+
(let* ((tmp (if ((if (null? catch-token-stack) valid-ir-return? simple-atom?) x)
42274224
#f
4228-
(make-ssavalue))))
4229-
(if tmp (emit `(= ,tmp ,x)))
4225+
(make-ssavalue)))
4226+
(x (if tmp
4227+
(begin (emit `(= ,tmp ,x)) tmp)
4228+
x))
4229+
(x (if rett
4230+
(compile (convert-for-type-decl x rett) '() #t #f)
4231+
x)))
42304232
(let ((pexc (pop-exc-expr catch-token-stack '())))
42314233
(if pexc (emit pexc)))
4232-
(emit `(return ,(or tmp x)))))
4234+
(emit `(return ,x))))
42334235
(if x
42344236
(if (> handler-level 0)
42354237
(let ((tmp (cond ((and (simple-atom? x) (or (not (ssavalue? x)) (not finally-handler))) #f)

test/syntax.jl

+4
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)