Skip to content

Commit 1b79373

Browse files
committed
Updating comment when calling foreach/where on emptyEnumerator
1 parent 1bdc9a9 commit 1b79373

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

  • src/System.Management.Automation/engine/runtime/Binding

src/System.Management.Automation/engine/runtime/Binding/Binders.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6689,14 +6689,14 @@ public override DynamicMetaObject FallbackInvokeMember(DynamicMetaObject target,
66896689
.WriteToDebugLog(this);
66906690
BindingRestrictions argRestrictions = args.Aggregate(BindingRestrictions.Empty, static (current, arg) => current.Merge(arg.PSGetMethodArgumentRestriction()));
66916691

6692+
// We need to pass the empty enumerator to the ForEach/Where operators, so that they can return an empty collection.
6693+
// The ForEach/Where operators will not be able to call the script block if the enumerator is empty.
66926694
if (s_whereSearchValues.Contains(Name))
66936695
{
66946696
return InvokeWhereOnCollection(emptyEnumerator, args, argRestrictions).WriteToDebugLog(this);
66956697
}
66966698

6697-
if (s_foreachSearchValues.Contains(Name))
6698-
// We need to pass the empty enumerator to the ForEach operator, so that it can return an empty collection.
6699-
// The ForEach operator will not be able to call the script block if the enumerator is empty.
6699+
if (s_foreachSearchValues.Contains(Name))
67006700
{
67016701
return InvokeForEachOnCollection(emptyEnumerator, args, argRestrictions).WriteToDebugLog(this);
67026702
}

0 commit comments

Comments
 (0)