Ensure null-coalescing LHS is evaluated only once#12667
Merged
iSazonov merged 4 commits intoPowerShell:masterfrom May 16, 2020
Merged
Ensure null-coalescing LHS is evaluated only once#12667iSazonov merged 4 commits intoPowerShell:masterfrom
iSazonov merged 4 commits intoPowerShell:masterfrom
Conversation
0407a9c to
fddb646
Compare
daxian-dbw
approved these changes
May 14, 2020
daxian-dbw
reviewed
May 14, 2020
iSazonov
reviewed
May 15, 2020
iSazonov
approved these changes
May 15, 2020
|
🎉 Handy links: |
|
🎉 Handy links: |
silijon
pushed a commit
to SkyKick/PowerShell
that referenced
this pull request
Jul 2, 2020
# Conflicts: # src/System.Management.Automation/engine/parser/Compiler.cs
22 tasks
21 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Summary
Fixes #12655.
The null coalescing operator currently double-evaluates its LHS, which is an issue if it has side effects. This changes evaluates the LHS, saves the result to a temporary variable and then proceeds with the conditional operator using the variable.
This PR also removes a redundant type check for AutomationNull that could never be satisfied due to the implementation of AutomationNull.
This PR should be considered for servicing in PS 7
PR Context
LHS in null coalescing expressions is currently double evaluated. It should only be evaluated once.
PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright headerWIP:or[ WIP ]to the beginning of the title (theWIPbot will keep its status check atPendingwhile the prefix is present) and remove the prefix when the PR is ready./cc @SeeminglyScience