From 27ae6215e227cf30679b0eef60064799c0c6d079 Mon Sep 17 00:00:00 2001 From: Valentin Churavy Date: Fri, 18 Aug 2023 11:56:03 -0400 Subject: [PATCH] The careful art of type-instability --- base/scopedvalues.jl | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/base/scopedvalues.jl b/base/scopedvalues.jl index fb28652937e1e..ea527f46af064 100644 --- a/base/scopedvalues.jl +++ b/base/scopedvalues.jl @@ -61,10 +61,11 @@ import Base: ImmutableDict # - Scopes are an inline implementation of an ImmutableDict, if we wanted # be really fance we could use a CTrie or HAMT. -mutable struct Scope{T} +mutable struct Scope const parent::Union{Nothing, Scope} - const key::ScopedValue{T} - const value::T + const key::ScopedValue + const value::Any + Scope(parent, key::ScopedValue{T}, value::T) where T = new(parent, key, value) end Scope(parent, key::ScopedValue{T}, value) where T = Scope(parent, key, convert(T, value))