-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Description
@JeffBezanson and I discussed this one (a long while ago) and I could have sworn I'd opened an issue about it, but I can't find it so perhaps I didn't. Whether a binding comes from a using
or not should be predictable from the content of a module, not what is done with the module. Example:
module A
x = 1
export x
end
module B
using A
x!(v) = global x = v
end
Currently, we can, in two separate Julia sessions, have B.x
either be an import from A
or be a global binding from B
, depending on what the caller does:
julia> module A
x = 1
export x
end
A
julia> module B
using A
x!(v) = global x = v
end
B
julia> B.x
1
julia> B.x!("bah")
WARNING: imported binding for x overwritten in module B
"bah"
Session 2:
julia> module A
x = 1
export x
end
A
julia> module B
using A
x!(v) = global x = v
end
B
julia> B.x!("bah");
julia> B.x
"bah"
Arguably, the definition of the function x!
which assigns B.x
should cause B.x
not to refer to A.x
, rather than the evaluation of x!
causing that binding to occur. Thus, in the first case, B.x
when occurring before any call to B.x!
should be an undefined reference. This may not be worth bothering with, but it could make life easier for static compilation and I really doubt many people are depending on the current behavior. cc @vtjnash