diff --git a/src/ScriptEngine/Machine/RuntimeScopes.cs b/src/ScriptEngine/Machine/RuntimeScopes.cs index b1e175d0f..88888251b 100644 --- a/src/ScriptEngine/Machine/RuntimeScopes.cs +++ b/src/ScriptEngine/Machine/RuntimeScopes.cs @@ -8,6 +8,7 @@ This Source Code Form is subject to the terms of the using System; using System.Collections; using System.Collections.Generic; +using System.Linq; using OneScript.Contexts; namespace ScriptEngine.Machine @@ -24,7 +25,7 @@ public class RuntimeScopes : IReadOnlyList public RuntimeScopes(IReadOnlyList outerScopes, AttachedContext innerScope) { - _outerScopes = outerScopes; + _outerScopes = outerScopes.Select(x => new AttachedContext(x.Instance)).ToList(); _innerScope = innerScope; _outerScopeLast = _outerScopes.Count - 1;