As of 1.5 I’m getting the new warning about global / local scope:
┌ Warning: Assignment to `#s262` in soft scope is ambiguous because a global variable by the same name exists: `#s262` will be treated as a new local. Disambiguate by using `local #s262` to suppress this warning or `global #s262` to assign to the existing global variable.
└ @ ~/.julia/dev/Stheno/src/gp/kernel.jl:510
I think I understand the new scoping rules, and I’m very appreciative of the clear warning message!
The thing that’s unclear to me is why I’m getting it in this case, as the warning appears to point towards a docstring.
The code in question is here:
https://github.com/willtebbutt/Stheno.jl/blob/68c4ce277ddc7284971232bf002d7e273a76039e/src/gp/kernel.jl#L510
Is anyone able to enlighten me?
1 Like
Reduced to
$ cat src/Debug.jl
module Debug
using Zygote: @adjoint
function foo end
@adjoint function foo(s, X::AbstractMatrix; dims=2)
D = foo(s, X; dims=dims)
return D, function(Δ)
d1, d2 = Diagonal(vec(sum(Δ; dims=1))), Diagonal(vec(sum(Δ; dims=2)))
return (nothing, X * (2 .* (d1 .+ d2 .- Δ .- Δ')))
end
end
include("file.jl")
end # module
$ cat src/file.jl
function bar end
@adjoint function bar(X::AbstractMatrix)
back(Δ::NamedTuple) = (Δ.X,)
back(Δ::AbstractMatrix) = (Δ,)
function back(Δ::AbstractVector{<:AbstractVector{<:Real}})
throw(error("In slow method"))
end
return bar(X), back
end
struct BlockData{T, V} <: AbstractVector{T}
X::Vector{V}
end
Perhaps an escaping issue with @adjoint
? Notably it does not happen if I combine the two files so my guess is that some counter is reset once Julia starts parsing the second file. So maybe a Julia bug too?
Edit: Here is the output:
julia> using Debug
[ Info: Precompiling Debug [7663d6bc-9f55-43cd-9496-9db996c1467b]
┌ Warning: Assignment to `#s28` in soft scope is ambiguous because a global variable by the same name exists: `#s28` will be treated as a new local. Disambiguate by using `local #s28` to suppress this warning or `global #s28` to assign to the existing global variable.
└ @ ~/dev/Debug/src/file.jl:12
julia> getproperty(Debug, Symbol("#s28"))
var"#s28"<:(AbstractArray{var"#s27",1} where var"#s27"<:Real)
4 Likes
Seems like an issue should be filed. Win for the new warning!
4 Likes
Thanks for digging down into this @fredrikekre – I don’t know where I would have started debugging this. You’re probably better placed than I am to open issues – I’m still not really sure what’s going on ![:joy: :joy:](https://emoji.discourse-cdn.com/twitter/joy.png?v=12)
2 Likes
This appears to have been resolved in 1.5.2!