Skip to content

Commit

Permalink
Fix captured static param lowering
Browse files Browse the repository at this point in the history
Captured static parameters by other methods of the same generic
closure were only added to the '(method ...) expr but not in the vinfo
of the '(lambda ...) if said parameter was not used in the definition.
Fixes #15180
  • Loading branch information
carnaval committed Feb 24, 2016
1 parent a02ecac commit c780e34
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/julia-syntax.scm
Original file line number Diff line number Diff line change
Expand Up @@ -2436,12 +2436,12 @@ f(x) = yt(x)
(define (clear-capture-bits vinfos)
(map vinfo:not-capt vinfos))

(define (convert-lambda lam fname interp)
(define (convert-lambda lam fname interp capt-sp)
`(lambda ,(lam:args lam)
(,(clear-capture-bits (car (lam:vinfo lam)))
()
,(caddr (lam:vinfo lam))
,(cadddr (lam:vinfo lam)))
,(delete-duplicates (append (lam:sp lam) capt-sp)))
,(add-box-inits-to-body
lam
(cl-convert (cadddr lam) fname lam (table) #f interp))))
Expand Down Expand Up @@ -2684,7 +2684,7 @@ f(x) = yt(x)
(cl-convert (cadddr lam2) 'anon lam2 (table) #f interp)))
,(last e))))
(else
(let* ((exprs (lift-toplevel (convert-lambda lam2 '|#anon| #t)))
(let* ((exprs (lift-toplevel (convert-lambda lam2 '|#anon| #t '())))
(top-stmts (cdr exprs))
(newlam (renumber-jlgensym (linearize (car exprs))))
(vi (lam:vinfo newlam))
Expand Down Expand Up @@ -2779,7 +2779,7 @@ f(x) = yt(x)
(if iskw
(caddr (lam:args lam2))
(car (lam:args lam2)))
#f)
#f capt-sp)
,(last e))))
,(if exists
'(null)
Expand Down
10 changes: 10 additions & 0 deletions test/core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3741,3 +3741,13 @@ let grphtest = ((1, [2]),)
for s = 1:1
end
end

# issue #15180
function f15180{T}(x::T)
X = Array(T, 1)
X[1] = x
@noinline ef{J}(::J) = (J,X[1]) # Use T
ef{J}(::J, ::Int) = (T,J)
return ef
end
@test map(f15180(1), [1,2]) == [(Int,1),(Int,1)]

0 comments on commit c780e34

Please sign in to comment.