Skip to content

Commit 6e5b031

Browse files
simeonschaubtkf
authored andcommitted
fix oc lowering with return type annotations (#44727)
fixes #44723 Co-authored-by: Takafumi Arakaki <aka.tkf@gmail.com> (cherry picked from commit 19eb307)
1 parent 8d13430 commit 6e5b031

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

src/julia-syntax.scm

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4018,7 +4018,7 @@ f(x) = yt(x)
40184018
(cons (car e)
40194019
(map-cl-convert (cdr e) fname lam namemap defined toplevel interp opaq))))))))
40204020

4021-
(define (closure-convert e) (cl-convert e #f #f #f #f #f #f #f))
4021+
(define (closure-convert e) (cl-convert e #f #f (table) (table) #f #f #f))
40224022

40234023
;; pass 5: convert to linear IR
40244024

@@ -4118,17 +4118,21 @@ f(x) = yt(x)
41184118
(loop (cdr s))))))
41194119
`(pop_exception ,restore-token))))
41204120
(define (emit-return x)
4121-
(define (actually-return x)
4122-
(let* ((x (if rett
4123-
(compile (convert-for-type-decl x rett) '() #t #f)
4124-
x))
4125-
(tmp (if ((if (null? catch-token-stack) valid-ir-return? simple-atom?) x)
4121+
(define (emit- x)
4122+
(let* ((tmp (if ((if (null? catch-token-stack) valid-ir-return? simple-atom?) x)
41264123
#f
41274124
(make-ssavalue))))
4128-
(if tmp (emit `(= ,tmp ,x)))
4125+
(if tmp
4126+
(begin (emit `(= ,tmp ,x)) tmp)
4127+
x)))
4128+
(define (actually-return x)
4129+
(let* ((x (if rett
4130+
(compile (convert-for-type-decl (emit- x) rett) '() #t #f)
4131+
x))
4132+
(x (emit- x)))
41294133
(let ((pexc (pop-exc-expr catch-token-stack '())))
41304134
(if pexc (emit pexc)))
4131-
(emit `(return ,(or tmp x)))))
4135+
(emit `(return ,x))))
41324136
(if x
41334137
(if (> handler-level 0)
41344138
(let ((tmp (cond ((and (simple-atom? x) (or (not (ssavalue? x)) (not finally-handler))) #f)

test/syntax.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3046,3 +3046,7 @@ end
30463046
let ex = :(const $(esc(:x)) = 1; (::typeof(2))() = $(esc(:x)))
30473047
@test macroexpand(Main, Expr(:var"hygienic-scope", ex, Main)).args[3].args[1] == :((::$(GlobalRef(Main, :typeof))(2))())
30483048
end
3049+
3050+
# issue 44723
3051+
demo44723()::Any = Base.Experimental.@opaque () -> true ? 1 : 2
3052+
@test demo44723()() == 1

0 commit comments

Comments
 (0)