New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Same param specified twice discards parameter variable attributes #3301
Comments
Don't have to dot-source PS /home/steve> param([ValidateSet('bar', 'baz')] [string] $Foo)
PS /home/steve>
PS /home/steve> # Output count of attributes.
PS /home/steve> (Get-Variable Foo).Attributes.Count
3
PS /home/steve> param([ValidateSet('bar', 'baz')] [string] $Foo)
PS /home/steve>
PS /home/steve> # Output count of attributes.
PS /home/steve> (Get-Variable Foo).Attributes.Count
0 |
@SteveL-MSFT - the interactive prompt is equivalent to dot sourcing. Dot sourcing just means - don't create a new scope. The interactive prompt executes everything in global scope which also means no new scope is created. |
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you. |
1 similar comment
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you. |
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you. |
This issue has been marked as "No Activity" as there has been no activity for 6 months. It has been closed for housekeeping purposes. |
Steps to reproduce
Create script
./script.ps1
as follows:Then dot-source the script twice:
Expected behavior
Actual behavior
Repeated dot-sourcing happens implicitly when you run your code repeatedly in the ISE, for instance.
Environment data
The text was updated successfully, but these errors were encountered: