Skip to content

Commit

Permalink
Fix no-arg ScopedValues.@with within a scope (#56019)
Browse files Browse the repository at this point in the history
Fixes #56017
  • Loading branch information
IanButterworth authored Oct 7, 2024
1 parent 4d21841 commit 57e3c9e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions base/scopedvalues.jl
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ struct Scope
values::ScopeStorage
end

Scope(scope::Scope) = scope

function Scope(parent::Union{Nothing, Scope}, key::ScopedValue{T}, value) where T
val = convert(T, value)
if parent === nothing
Expand Down
6 changes: 6 additions & 0 deletions test/scopedvalues.jl
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,12 @@ end
@test sval[] == 1
@test sval_float[] == 1.0
end
@with sval=>2 sval_float=>2.0 begin
@with begin
@test sval[] == 2
@test sval_float[] == 2.0
end
end
end

@testset "isassigned" begin
Expand Down

0 comments on commit 57e3c9e

Please sign in to comment.