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 ec812ac commit e42b26e
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 @@ -2453,12 +2453,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 @@ -2701,7 +2701,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 @@ -2796,7 +2796,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 @@ -3777,3 +3777,13 @@ let ex = quote
end
@test ex.args[2] == :test
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 e42b26e

Please sign in to comment.