Closed akpaevj closed 1 month ago
The changes involve an update to the RuntimeScopes
class constructor, specifically in how the _outerScopes
field is initialized. The previous implementation directly assigned the outerScopes
parameter to _outerScopes
, while the new implementation uses LINQ's Select
method to create a new list of AttachedContext
instances. This ensures that _outerScopes
contains distinct instances rather than references to the original objects.
File | Change Summary |
---|---|
src/ScriptEngine/Machine/RuntimeScopes.cs | Updated _outerScopes initialization to use LINQ's Select for creating distinct AttachedContext instances. |
In the code where rabbits play,
Distinct instances hop and sway.
With LINQ's magic, they now gleam,
A list of contexts, like a dream.
Hooray for changes, bright and new,
A joyful leap, we bid adieu! 🐇✨
src/ScriptEngine/Machine/RuntimeScopes.cs (2)
`11-11`: **LGTM: Added necessary using statement** The addition of `using System.Linq;` is appropriate as it's required for the LINQ operations used in the constructor. --- `28-28`: **Approved, but clarification needed on necessity and performance** The change to create new `AttachedContext` instances ensures that `_outerScopes` contains distinct objects rather than references to the original ones. This could prevent unintended modifications to the original `outerScopes` objects. However, I have a few questions: 1. Could you clarify why this change was necessary? Are there specific scenarios where modifying the original `outerScopes` objects caused issues? 2. Have you considered the potential performance impact of this change, especially for large `outerScopes` lists? To assess the usage and potential impact, let's analyze the codebase:
(не успел немного)
Проблема устраняется, но не в том месте, где возникла.
Достаточно в LibraryLoader.AddModule() после строки
https://github.com/EvilBeaver/OneScript/blob/48446293578ca25910477111e507a539be66c1ab/src/ScriptEngine.HostedScript/LibraryLoader.cs#L115
Выполнить повторный Attach для MachineInstance.Current._globalContexts
(точнее, для одного _globalContexts[0])
! Начал падать tests\eval.os: ТестДолжен_ПроверитьРекурсивныйВызовВыполнить ТестДолжен_ПроверитьВызовыВыполнитьСПопытками
! Начал падать tests\eval.os: ТестДолжен_ПроверитьРекурсивныйВызовВыполнить ТестДолжен_ПроверитьВызовыВыполнитьСПопытками
Забрал себе
Summary by CodeRabbit
AttachedContext
are used, enhancing stability and performance.