Unexpected behavior of AutomationNull in object initializers using [pscustomobject] #19552
Closed
5 tasks done
Labels
Needs-Triage
The issue is new and needs to be triaged by a work group.
Resolution-No Activity
Issue has had no activity for 6 months or more
Prerequisites
Steps to reproduce
Note: Initializing via
[hashtable]
used to break too, but that was fixed in #19402 / #19415.In an array-type-constrained variable (as in expressions in general), AutomationNull is treated like
$null
; e.g.:By contrast, using AutomationNull in
[pscustomobject]
-based object initializers fails:The symptom is reminiscent of #19384 (comment)
Expected behavior
An
[Example]
instance should be constructed, with$null
returned from its .LogMessage property.Note: If this is resolved in the same way as for hashtable initializers, it is actually
[System.Management.Automation.Internal.AutomationNull]::Value
that is stored in the property, but on accessing (getting) it, it turns to$null
.Outside of a class this behavior is directly visible:
Actual behavior
Error details
No response
Environment data
Visuals
No response
The text was updated successfully, but these errors were encountered: