Skip to content

Should we detect/Deny using $_ as a user defined variable? #3695

@jpsnover

Description

@jpsnover

This works but it seems like terrible practice - should we detect/deny using $_ as a user defined variable?
(At PSCONF.EU and a customer's colleague is doing this in his code)

foreach ($_ in gps | where {$.name -like "*SS"})
{
$
.name
}

This also works:

$_ = "test"
write-host -ForegroundColor red "Thiis is a $_ "

Metadata

Metadata

Assignees

No one assigned

    Labels

    Breaking-Changebreaking change that may affect usersCommittee-ReviewedPS-Committee has reviewed this and made a decisionIssue-Discussionthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifResolution-Won't FixThe issue won't be fixed, possibly due to compatibility reason.WG-Languageparser, language semantics

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions