Skip to content

Throw a warning when I redefine a global variable in a local scope #265

Open
@joeyaiello

Description

@joeyaiello

Like the title says, it would be useful if I was warned whenever I try to reuse a global variable's name in a more local scope.

$a = 'Unchanged'
function foo {
    Write-Host "foo can read `$a : `$a = $a"
    $a = 'Changed from foo' # this should be warning!!
    Write-Host "foo can change it's own copy of `$a: `$a = $a"
}
foo
Write-Host "After foo call: `$a = $a"

Thanks to @vors for the example.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions