-
Notifications
You must be signed in to change notification settings - Fork 8.4k
Write-Output -NoEnumerate doesn't handle Hashtable properly #14047
Copy link
Copy link
Closed
Labels
Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aResolution-No ActivityIssue has had no activity for 6 months or moreIssue has had no activity for 6 months or moreWG-Enginecore PowerShell engine, interpreter, and runtimecore PowerShell engine, interpreter, and runtime
Metadata
Metadata
Assignees
Labels
Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aResolution-No ActivityIssue has had no activity for 6 months or moreIssue has had no activity for 6 months or moreWG-Enginecore PowerShell engine, interpreter, and runtimecore PowerShell engine, interpreter, and runtime
Type
Fields
Give feedbackNo fields configured for issues without a type.
Steps to reproduce
Expected behavior
$h["foo"] # returns 1$h.count # returns 2Actual behavior
$h["foo"] # returns $null$h.count # returns 1Environment data
Notes
I thought I would use
end { Write-Output $Result -NoEnumerate }to be safe forConvertTo-Dictionarythe way I do to ensure an empty HashSet is returned byConvertTo-HashSetwhen pipeline input is empty, but it turns out you must useend { $Result }or you get back a broken Hashtable.Maybe this is expected behavior somehow, but I don't understand what $h is and how $h."foo" and $h."bar" both work even though $h.count is 1. And why $h.keys gives 2 items, while $h.count is 1. I guess $h is being unrolled and that is how it is working. Still, not what I would have expected from -NoEnumerate.