Skip to content
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
22 changes: 16 additions & 6 deletions src/julia-syntax.scm
Original file line number Diff line number Diff line change
Expand Up @@ -2599,11 +2599,13 @@
(typ-svec (caddr sig-svec))
(tvars (cddr (cadddr sig-svec)))
(argtypes (cdddr typ-svec))
(functionloc (cadr (caddddr sig-svec))))
(let* ((argtype (foldl (lambda (var ex) `(call (core UnionAll) ,var ,ex))
(expand-forms `(curly (core Tuple) ,@argtypes))
(reverse tvars))))
`(_opaque_closure ,(or argt argtype) ,rt_lb ,rt_ub ,isva ,(length argtypes) ,allow-partial ,functionloc ,lam))))
(functionloc (cadr (caddddr sig-svec)))
(argtype (foldl (lambda (var ex) `(call (core UnionAll) ,var ,ex))
(expand-forms `(curly (core Tuple) ,@argtypes))
(reverse tvars)))
(argtype (or argt argtype))
(argtype (if (null? stmts) argtype `(block ,@stmts ,argtype))))
`(_opaque_closure ,argtype ,rt_lb ,rt_ub ,isva ,(length argtypes) ,allow-partial ,functionloc ,lam)))

'block
(lambda (e)
Expand Down Expand Up @@ -5232,6 +5234,14 @@ f(x) = yt(x)
(define (set-lineno! lineinfo num)
(set-car! (cddr lineinfo) num))

;; note that the 'list and 'block atoms make all lists 1-indexed.
;; returns a 5-element vector containing:
;; code: `(block ,@(n expressions))
;; locs: list of line-table index, where code[i] has lineinfo line-table[locs[i]]
;; line-table: list of `(lineinfo file.jl 123 0)'
;; ssavalue-table: table of (ssa-num . code-index)
;; where ssavalue references in `code` need this remapping
;; label-table: table of (label . code-index)
(define (compact-ir body file line)
(let ((code '(block))
(locs '(list))
Expand Down Expand Up @@ -5338,7 +5348,7 @@ f(x) = yt(x)
e)
((ssavalue? e)
(let ((idx (get ssavalue-table (cadr e) #f)))
(if (not idx) (begin (prn e) (prn lam) (error "ssavalue with no def")))
(if (not idx) (error "ssavalue with no def"))
`(ssavalue ,idx)))
((eq? (car e) 'goto)
`(goto ,(get label-table (cadr e))))
Expand Down
3 changes: 3 additions & 0 deletions test/opaque_closure.jl
Original file line number Diff line number Diff line change
Expand Up @@ -407,3 +407,6 @@ let f = f54357(+, Tuple{Int,Int})
@test g isa Core.OpaqueClosure
@test g(32.0, 34.0) === 66.0
end

# 49659: signature-scoped typevar shouldn't fail in lowering
@test_throws "must be a tuple type" @opaque ((x::T,y::T) where {T}) -> 123