Skip to content

[type] cast and -as [Type] malfunction with strings that contain "]" (only) #19559

@mklement0

Description

@mklement0

Prerequisites

Steps to reproduce

# OK
[Type] 'int'
'int' -as [Type]

# !! BROKEN - these calls succeed, despite obviously broken input.
# Note that prepending "[" *would* fail, as expected, given that [Type] "[int]" doesn't - and shouldn't - work.
# It doesn't matter what, if anything, follows the closing-only "]"
[Type] 'int]whatever'
'int]whatever' -as [Type]

Expected behavior

Output of two [type] instances, and two errors.

Actual behavior

Output of four [int] instances. That is, the broken type names were unexpectedly accepted.

Error details

No response

Environment data

PowerShell Core 7.4.0-preview.3

Visuals

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions