From 63ad813cf83a5d21d24ccf1556b684df865d5d7e Mon Sep 17 00:00:00 2001 From: Ian Butterworth Date: Sun, 6 Oct 2024 15:20:23 -0400 Subject: [PATCH] fix no arg `@with` within a scope --- base/scopedvalues.jl | 4 ++++ test/scopedvalues.jl | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/base/scopedvalues.jl b/base/scopedvalues.jl index 6ccd4687c5c65..fefcfdfccd5ba 100644 --- a/base/scopedvalues.jl +++ b/base/scopedvalues.jl @@ -85,6 +85,10 @@ struct Scope values::ScopeStorage end +function Scope(parent::Scope) + return Scope(parent.values) +end + function Scope(parent::Union{Nothing, Scope}, key::ScopedValue{T}, value) where T val = convert(T, value) if parent === nothing diff --git a/test/scopedvalues.jl b/test/scopedvalues.jl index 61b10c557c455..2c2f4a510c1c9 100644 --- a/test/scopedvalues.jl +++ b/test/scopedvalues.jl @@ -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