Skip to content

Commit

Permalink
fix JuliaLang#28044, collision between global and where-bound var
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson committed Jul 11, 2018
1 parent b0240d9 commit 3a4c05e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/jlfrontend.scm
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,15 @@
tab)))
((lambda) tab)
((local) tab)
((scope-block)
;; TODO: when deprecation for implicit global assignment inside loops
;; is removed, remove this code and just return `tab` in this case
(let ((tab2 (table)))
(find-possible-globals- (cadr e) tab2)
(for-each (lambda (v) (if (has? tab2 v) (del! tab2 v)))
(append (find-local-decls (cadr e)) (find-local-def-decls (cadr e))))
(for-each (lambda (v) (put! tab v #t))
(table.keys tab2))))
((break-block) (find-possible-globals- (caddr e) tab))
((module toplevel) '())
(else
Expand Down
11 changes: 11 additions & 0 deletions test/syntax.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1559,3 +1559,14 @@ let oldstderr = stderr, newstderr, errtxt
end
@test occursin("WARNING: local variable B conflicts with a static parameter", fetch(errtxt))
end

# issue #28044
code28044(x) = 10x
begin
function f28044(::Val{code28044}) where code28044
code28044(2)
end
# make sure this assignment to `code28044` doesn't add an implicit-global
Val{code28044} where code28044
end
@test f28044(Val(identity)) == 2

0 comments on commit 3a4c05e

Please sign in to comment.