10BC0 Still some bugs in error formatting, indent somehow involved · Issue #11669 · PowerShell/PowerShell · GitHub
[go: up one dir, main page]

Skip to content

Still some bugs in error formatting, indent somehow involved #11669

@jazzdelightsme

Description

@jazzdelightsme

Steps to reproduce

N.B. The repro code is indented. THIS IS CRUCIAL TO THE REPRO. Include the indent when copying and pasting into your console window.

        $CopyErrors = New-Object 'System.Collections.ArrayList'

        function CopyFiles( $srcRoot, $destRoot, $plat )
        {
            Write-Host "Copying binaries from $($srcRoot)..." -Fore Green

            $fullSrc = 'C:\Windows\system32\ntdll.dll'
            $fullDst = 'C:\does\not\exist'

            Copy-Item $fullSrc $fullDst -ErrorVariable +CopyErrors
        }

        CopyFiles

        $CopyErrors

        $error.Count

        $error

        $error.Count

Expected behavior

You should see 1 error, from outputting $CopyErrors, then $error.Count should output "1", then $error should show that same error again, then $error.Count should still be "1".

Actual behavior

During the formatting of $CopyErrors, things go sideways, and the errors don't appear in the console, but carnage starts accumulating in $error. Here are the printable errors:

MethodInvocationException:
Line |
 122 |  …             $line = $line.Insert($offsetInLine

     |                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Exception calling "Insert" with "2" argument(s): "Specified argument was out of the range of valid values. (Parameter 'startIndex')"

MethodInvocationException:
Line |
 122 |  …             $line = $line.Insert($offsetInLine

     |                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Exception calling "Insert" with "2" argument(s): "Specified argument was out of the range of valid values. (Parameter 'startIndex')"

Environment data

Name                           Value
----                           -----
PSVersion                      7.0.0-rc.2
PSEdition                      Core
GitCommitId                    7.0.0-rc.2
OS                             Microsoft Windows 10.0.18363
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.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0