Skip to content

Commit 19eb307

Browse files
simeonschaubtkf
andauthored
fix oc lowering with return type annotations (#44727)
fixes #44723 Co-authored-by: Takafumi Arakaki <aka.tkf@gmail.com>
1 parent 9d31f6a commit 19eb307

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

src/julia-syntax.scm

+12-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

@@ -4219,17 +4219,21 @@ f(x) = yt(x)
42194219
(loop (cdr s))))))
42204220
`(pop_exception ,restore-token))))
42214221
(define (emit-return x)
4222-
(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)
4222+
(define (emit- x)
4223+
(let* ((tmp (if ((if (null? catch-token-stack) valid-ir-return? simple-atom?) x)
42274224
#f
42284225
(make-ssavalue))))
4229-
(if tmp (emit `(= ,tmp ,x)))
4226+
(if tmp
4227+
(begin (emit `(= ,tmp ,x)) tmp)
4228+
x)))
4229+
(define (actually-return x)
4230+
(let* ((x (if rett
4231+
(compile (convert-for-type-decl (emit- x) rett) '() #t #f)
4232+
x))
4233+
(x (emit- x)))
42304234
(let ((pexc (pop-exc-expr catch-token-stack '())))
42314235
(if pexc (emit pexc)))
4232-
(emit `(return ,(or tmp x)))))
4236+
(emit `(return ,x))))
42334237
(if x
42344238
(if (> handler-level 0)
42354239
(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()::Any = Base.Experimental.@opaque () -> true ? 1 : 2
3282+
@test demo44723()() == 1

0 commit comments

Comments
 (0)