Skip to content

Commit

Permalink
Make Scope immutable (#51976)
Browse files Browse the repository at this point in the history
Addresses keno review comment in
#50958 (comment)
  • Loading branch information
vchuravy authored Nov 2, 2023
1 parent 013311c commit 06de99e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions base/scopedvalues.jl
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Base.isassigned(val::ScopedValue) = val.has_default

const ScopeStorage = Base.PersistentDict{ScopedValue, Any}

mutable struct Scope
struct Scope
values::ScopeStorage
end

Expand Down Expand Up @@ -114,15 +114,15 @@ function get(val::ScopedValue{T}) where {T}
# Inline current_scope to avoid doing the type assertion twice.
scope = current_task().scope
if scope === nothing
isassigned(val) && return Some(val.default)
isassigned(val) && return Some{T}(val.default)
return nothing
end
scope = scope::Scope
if isassigned(val)
return Some(Base.get(scope.values, val, val.default)::T)
return Some{T}(Base.get(scope.values, val, val.default)::T)
else
v = Base.get(scope.values, val, novalue)
v === novalue || return Some(v::T)
v === novalue || return Some{T}(v::T)
end
return nothing
end
Expand Down

0 comments on commit 06de99e

Please sign in to comment.