Skip to content

Conversation

@JeffBezanson
Copy link
Member

Before:

julia> begin
       sin(2)
       global sin = 1
       end
ERROR: cannot assign variable Base.sin from module Main

julia> begin
       cos(2)
       global cos = 1
       while false end
       end
ERROR: UndefVarError: cos not defined

This is because the second one is compiled, causing us to do early resolution of globals that the block might create (via global cos = 1). With this change, both give an UndefVarError.

@JeffBezanson
Copy link
Member Author

Ok, this is probably not quite right. It would break something like

if condition
    using Foo
else
    global myfoo = ...
end

@JeffBezanson JeffBezanson deleted the jb/toplevel_resolve_globals branch February 6, 2018 22:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant