Skip to content

Commit

Permalink
fix JuliaLang#28399, incorrect variable capture causing internal comp…
Browse files Browse the repository at this point in the history
…iler error (JuliaLang#28404)
  • Loading branch information
JeffBezanson authored and StefanKarpinski committed Aug 2, 2018
1 parent 2c08695 commit 0e20855
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/julia-syntax.scm
Original file line number Diff line number Diff line change
Expand Up @@ -2648,7 +2648,7 @@
(define (free-vars- e tab)
(cond ((or (eq? e 'true) (eq? e 'false) (eq? e UNUSED)) tab)
((symbol? e) (put! tab e #t))
((and (pair? e) (eq? (car e) 'outerref)) (put! tab (cadr e) #t))
((and (pair? e) (eq? (car e) 'outerref)) tab)
((and (pair? e) (eq? (car e) 'break-block)) (free-vars- (caddr e) tab))
((and (pair? e) (eq? (car e) 'with-static-parameters)) (free-vars- (cadr e) tab))
((or (atom? e) (quoted? e)) tab)
Expand Down
18 changes: 18 additions & 0 deletions test/core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6656,3 +6656,21 @@ end
# Issue #28392
struct Foo28392; end
@test_throws MethodError iterate(Foo28392())

# issue #28399
function g28399(n)
for a = 1:n
c28399 = 1
end
()->c28399
end
function f28399()
for a = __undef_28399__
c28399 = 1
end
()->c28399
end
c28399 = 42
@test g28399(0)() == 42
@test g28399(1)() == 42
@test_throws UndefVarError(:__undef_28399__) f28399()

0 comments on commit 0e20855

Please sign in to comment.