SeeminglyScience / dotfiles

Other
34 stars 3 forks source link

Breakpoints error when using Select-ObjectIndex #1

Open ninmonkey opened 1 year ago

ninmonkey commented 1 year ago

About

image

Possible Causes

Because when debugging things, you can easily wrap 255.

To Reproduce

In my testing, it felt like it was split, either: 100% it would reproduce, or 0%

$Error.count  # returns 130 # existing errors
$Error | Utility\Select-ObjectIndex 0
      # <the first time you get the right error>

$Error | Utility\Select-ObjectIndex 3        # errors don't print
$Error | Utility\Select-ObjectIndex 0        # errors don't print

> Collection was modified, cannot enumerate. 

Once it starts, you can only reference the error in some ways. So when debugging it -- make sure your prompt has $error.count in it. In the screenshot, Select-Object adds 3 errors, every time ( Maybe it hints to the uncaught error being fired inside the formatter? )

# 169!7.2.6
Pwsh> $error | Select-Object -First 3

# 172!7.2.6
Pwsh> $error | select -First 10

#175!7.2.6
Pwsh> $error | select -First 10

image

ninmonkey commented 1 year ago

Possibly related, I noticed that they end up copying by value, not ref, $serr = $error does not.

$serr = $error
$serr2 = $error | select -first 3
$serr3 = $error[0..2]

At least in this case, $serr2, $serr3's version did not increase in count, but $serr does.

$serr2.count; $serr.count; $serr3.Count ;1 /0; $serr2.count; $serr.count; $serr3.Count