Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

disallow 'global x' when x exists in outer scope #11985

Merged
merged 1 commit into from
Jul 3, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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