-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Mutable let block variable treated as immutable in Julia 1.10 #52531
Comments
@aviatesk this seems possibly effects related. It seems like we might miss-model the
|
Why is
So we decided to concrete eval it, but we shouldn't have since the getfield is |
I will look into this tomorrow. It's certainly a bug of the effects system. |
On main we get even further xD:
|
I think the bigger question is why is |
If read that right, it is saying the result is consistent as long as the return value is immutable (since then we didn't use the result of that load?), which, since we asserted the return value is an Int, it thus determines the result is consistent? |
So maybe it's |
vs
|
Those effects for box seem fine though, the weird thing is that |
We can also observe the same for
|
julia> const a = Core.Ref(1)
Base.RefValue{Int64}(1)
julia> @eval getref() = $(QuoteNode(a)).x
getref (generic function with 1 method)
julia> Base.infer_effects(getref,())
(+c,+e,+n,+t,+s,+m,+u)
julia> getref()
1
julia> a.x = 9
9
julia> getref()
9
julia/base/compiler/typeinfer.jl Lines 483 to 490 in 0c46852
I suspect that the else if branch here is incorrect. We don't refine the memory effects after this, so this function will never be consistent. |
So testing just removing those |
I'm not sure this is 100% fixed, the original issue in ParallelStencil still seems to be there |
New MWE julia> foo(x) = (set_initialized(true); nothing)
foo (generic function with 1 method)
julia> let
global is_initialized, set_initialized
_is_initialized = false
set_initialized(flag::Bool) = (_is_initialized = flag)
is_initialized() = _is_initialized
end
is_initialized (generic function with 1 method)
julia> @show is_initialized()
is_initialized() = false
false
julia> @show set_initialized(true)
set_initialized(true) = true
true
julia> @show is_initialized()
is_initialized() = true
true
julia> @show set_initialized(false)
set_initialized(false) = false
false
julia> @show is_initialized()
is_initialized() = false
false
julia> foo(4)
julia> @show is_initialized()
is_initialized() = false
false |
NVM... I didn't define set_initalize |
Yes inside The Box is not lowered to be a QuoteNode. It's just a Box. That feels wrong since Box is not defined to be self-quoting... |
`Core.Box` is not self-quoting so it should be captured in a QuoteNode. This has been benign until the improved effect system, we handle `QuoteNode` of a mutable value as a global access, whereas a direct reference to a value is treated as inaccessible memory. Fixes #52531 --------- Co-authored-by: Gabriel Baraldi <[email protected]> Co-authored-by: Shuhei Kadowaki <[email protected]>
`Core.Box` is not self-quoting so it should be captured in a QuoteNode. This has been benign until the improved effect system, we handle `QuoteNode` of a mutable value as a global access, whereas a direct reference to a value is treated as inaccessible memory. Fixes #52531 --------- Co-authored-by: Gabriel Baraldi <[email protected]> Co-authored-by: Shuhei Kadowaki <[email protected]> (cherry picked from commit 1290b51)
…edded to IR Fixes another variant of JuliaLang#52531.
…ng#52878) Issues like JuliaLang#52531 were more broadly fixed by JuliaLang#52856. This commit partially reverts JuliaLang#52596, while leaving the added tests.
MWE:
Wrong output in Julia 1.10:
Correct output in Julia 1.9.4:
The text was updated successfully, but these errors were encountered: