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

Lowering: Insert QuoteNode for captured boxed value #52596

Merged
merged 3 commits into from
Dec 22, 2023
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
2 changes: 1 addition & 1 deletion src/julia-syntax.scm
Original file line number Diff line number Diff line change
Expand Up @@ -3586,7 +3586,7 @@ f(x) = yt(x)
(rhs (convert-for-type-decl rhs1 (cl-convert vt fname lam #f #f #f interp opaq (table) locals) #t lam))
(ex (cond (closed `(call (core setfield!)
,(if interp
`($ ,var)
`($ (call (core QuoteNode) ,var))
(capt-var-access var fname opaq))
(inert contents)
,rhs))
Expand Down
17 changes: 15 additions & 2 deletions test/compiler/effects.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1347,16 +1347,29 @@ const a52531 = Core.Ref(1)
@test !Core.Compiler.is_consistent(Base.infer_effects(getref52531))
let
global set_a52531!, get_a52531
_a::Int = -1
_a::Int = -1
set_a52531!(a::Int) = (_a = a; return get_a52531())
get_a52531() = _a
get_a52531() = _a
end
@test !Core.Compiler.is_consistent(Base.infer_effects(set_a52531!, (Int,)))
@test !Core.Compiler.is_consistent(Base.infer_effects(get_a52531, ()))
@test get_a52531() == -1
@test set_a52531!(1) == 1
@test get_a52531() == 1

let
global is_initialized52531, set_initialized52531!
_is_initialized = false
set_initialized52531!(flag::Bool) = (_is_initialized = flag)
is_initialized52531() = _is_initialized
end
top_52531(_) = (set_initialized52531!(true); nothing)
@test !Core.Compiler.is_consistent(Base.infer_effects(is_initialized52531))
@test !Core.Compiler.is_removable_if_unused(Base.infer_effects(set_initialized52531!, (Bool,)))
@test !is_initialized52531()
top_52531(0)
@test is_initialized52531()

@test Core.Compiler.is_inaccessiblememonly(Base.infer_effects(identity∘identity, Tuple{Any}))
@test Core.Compiler.is_inaccessiblememonly(Base.infer_effects(()->Vararg, Tuple{}))

Expand Down