Skip to content

Commit

Permalink
disallow nested 'global x' if x is local variable in enclosing scope
Browse files Browse the repository at this point in the history
fixes #7264
  • Loading branch information
ihnorton committed Jul 3, 2015
1 parent 2cbb72a commit 9a4c0d8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ Language changes
* Triple-quoted strings no longer treat tabs as 8 spaces. Instead, the
longest common prefix of spaces and tabs is removed.

* `global x` in a nested scope is now a syntax error if `x` is local
to the enclosing scope ([#7264]/[#11985]).

Command line option changes
---------------------------

Expand Down
7 changes: 6 additions & 1 deletion src/julia-syntax.scm
Original file line number Diff line number Diff line change
Expand Up @@ -3229,7 +3229,12 @@ So far only the second case can actually occur.
(mark-label endl))
))

((global) #f) ; remove global declarations
((global) ; remove global declarations
(let ((vname (cadr e)))
(if (var-info-for vname vi)
; issue #7264
(error (string "`global " vname "`: " vname " is local variable in the enclosing scope"))
#f)))
((implicit-global) #f)
((local!) #f)
((jlgensym) #f)
Expand Down

0 comments on commit 9a4c0d8

Please sign in to comment.