Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix oc lowering with return type annotations #44727

Merged
merged 2 commits into from
Mar 27, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix oc lowering with return type annotations
fixes #44723
  • Loading branch information
simeonschaub committed Mar 24, 2022
commit 498754de15610dd8803742a983e85b9ac9724f0f
20 changes: 12 additions & 8 deletions src/julia-syntax.scm
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -4219,17 +4219,21 @@ f(x) = yt(x)
(loop (cdr s))))))
`(pop_exception ,restore-token))))
(define (emit-return x)
(define (actually-return x)
(let* ((x (if rett
(compile (convert-for-type-decl x rett) '() #t #f)
x))
(tmp (if ((if (null? catch-token-stack) valid-ir-return? simple-atom?) x)
(define (emit- x)
(let* ((tmp (if ((if (null? catch-token-stack) valid-ir-return? simple-atom?) x)
#f
(make-ssavalue))))
(if tmp (emit `(= ,tmp ,x)))
(if tmp
(begin (emit `(= ,tmp ,x)) tmp)
x)))
(define (actually-return x)
(let* ((x (if rett
(compile (convert-for-type-decl (emit- x) rett) '() #t #f)
x))
(x (emit- x)))
(let ((pexc (pop-exc-expr catch-token-stack '())))
(if pexc (emit pexc)))
(emit `(return ,(or tmp x)))))
(emit `(return ,x))))
(if x
(if (> handler-level 0)
(let ((tmp (cond ((and (simple-atom? x) (or (not (ssavalue? x)) (not finally-handler))) #f)
Expand Down
4 changes: 4 additions & 0 deletions test/syntax.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
simeonschaub marked this conversation as resolved.
Show resolved Hide resolved