-
Notifications
You must be signed in to change notification settings - Fork 229
Open
Labels
Description
Describe the bug
got exception when use with block inside each
Expected behavior:
no exception
Test to reproduce
{{#each Fields}}
{{#with this as | field |}} <------------------ blockParamsValues[0] = arguments[0]; will fail here during the loop.
{{#each (Getattributes field)}} <------------------ then 'field' here will got exception.
{{this}}
{{/each}}
{{/with}}
{{/each}}
Other related info
I got the exception from debugger and find that the bug is caused by :
internal struct BindingContextPolicy : IInternalObjectPoolPolicy
{
public BindingContext Create() => new BindingContext();
public bool Return(BindingContext item)
{
item.Root = null;
item.Value = null;
item.ParentContext = null;
item.PartialBlockTemplate = null;
item.InlinePartialTemplates.Clear();
item.Helpers.Clear();
item.BlockHelpers.Clear();
item.Bag.Clear();
item.BlockParamsObject.OptionalClear(); // <------------ bug caused by this
item.ContextDataObject.OptionalClear();
item.Descriptor.Reset();
return true;
}
}
in the with WithBlockHelperDescriptor :
using var frame = options.CreateFrame(arguments[0]);
var blockParamsValues = frame.BlockParams(options.BlockVariables);
blockParamsValues[0] = arguments[0]; // <---------------- when BindingContext got from pool and frame.BlockParamsObject has the key already, but has count == 0 ( Reset by OptionalClear ), in FixedSizeDictionary.AddOrReplace(variable, value, out _); the key, value will be set correctly, but the count is still 0.