8000 The null-coalescing operator evaluates the left-hand operand twice. · Issue #12655 · PowerShell/PowerShell · GitHub
[go: up one dir, main page]

Skip to content

The null-coalescing operator evaluates the left-hand operand twice. #12655

@chtoucas

Description

@chtoucas

Steps to reproduce

function A {
    Write-Host "In A"
    return "something"
}

# Here, A is called twice
$y = (A) ?? "blabla"

Expected behavior

The function A should be called only once.

In A

Actual behavior

The function A is called twice.

In A
In A

Environment data

Name                           Value
----                           -----
PSVersion                      7.0.0
PSEdition                      Core
GitCommitId                    7.0.0
OS                             Microsoft Windows 10.0.18362
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Metadata

Metadata

Assignees

Labels

Issue-BugIssue has been identified as a bug in the productResolution-FixedThe issue is fixed.WG-Enginecore PowerShell engine, interpreter, and runtime

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0