-
Notifications
You must be signed in to change notification settings - Fork 7.9k
[WIP] Fix using variable error for nested foreach parallel #11829
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@PaulHigin would this fix also affect the use of nested iterations of |
src/System.Management.Automation/engine/runtime/ScriptBlockToPowerShell.cs
Outdated
Show resolved
Hide resolved
src/System.Management.Automation/engine/runtime/ScriptBlockToPowerShell.cs
Outdated
Show resolved
Hide resolved
src/System.Management.Automation/engine/runtime/ScriptBlockToPowerShell.cs
Outdated
Show resolved
Hide resolved
src/System.Management.Automation/engine/runtime/ScriptBlockToPowerShell.cs
Outdated
Show resolved
Hide resolved
…owerShell.cs Co-Authored-By: Ilya <[email protected]>
…owerShell.cs Co-Authored-By: Ilya <[email protected]>
…owerShell.cs Co-Authored-By: Ilya <[email protected]>
…owerShell.cs Co-Authored-By: Ilya <[email protected]>
@vexx32 No, ThreadJob will also need to change. Please create an issue for it. |
src/System.Management.Automation/engine/runtime/ScriptBlockToPowerShell.cs
Outdated
Show resolved
Hide resolved
Just double checked it, and looks like |
Will this be added to RC3? |
@PrzemyslawKlys I don't think so, as the RC3 is already locked down and we have a very high bar for GA. But this fix will be included in a servicing release later. |
This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days. |
What is the status of this PR? |
AFAIK there is no reason not to take this PR. @daxian-dbw can we include this in the next preview release? |
@PaulHigin Please rebase to pass CIs. |
Closing this PR since it is so old, and created a new one (#14548) |
PR Summary
This fixes a bug in ForEach-Object -Parallel where a using variable in a nested ForEach-Object -Parallel throws an error even when the variable is defined in the correct scope (Issue #11817).
PR Context
This error was occurring because, when ForEach-Object -Parallel was assembling the user variable map, it was searching all nested scriptblocks within the ForEach scriptblock, with the result of finding nested using variables where the variable had not yet been defined. Since the nested scriptblock using variable had not been defined in the current scope, a mapping error was thrown.
Fix is to change the using variable map function to not search nested scriptblocks in the ForEach -Parallel case. This way foreach -parallel using variable mapping is always performed only for the current scope.
Many thanks to @mklement0 for pointing out the fix.
PR Checklist
.h
,.cpp
,.cs
,.ps1
and.psm1
files have the correct copyright headerWIP:
or[ WIP ]
to the beginning of the title (theWIP
bot will keep its status check atPending
while the prefix is present) and remove the prefix when the PR is ready.