Skip to content

Commit 57e3c9e

Browse files
Fix no-arg ScopedValues.@with within a scope (#56019)
Fixes #56017
1 parent 4d21841 commit 57e3c9e

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

base/scopedvalues.jl

+2
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ struct Scope
8585
values::ScopeStorage
8686
end
8787

88+
Scope(scope::Scope) = scope
89+
8890
function Scope(parent::Union{Nothing, Scope}, key::ScopedValue{T}, value) where T
8991
val = convert(T, value)
9092
if parent === nothing

test/scopedvalues.jl

+6
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,12 @@ end
138138
@test sval[] == 1
139139
@test sval_float[] == 1.0
140140
end
141+
@with sval=>2 sval_float=>2.0 begin
142+
@with begin
143+
@test sval[] == 2
144+
@test sval_float[] == 2.0
145+
end
146+
end
141147
end
142148

143149
@testset "isassigned" begin

0 commit comments

Comments
 (0)