Skip to content

No linting error on wrong array types #4807

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

Closed
5 tasks done
Malix-Labs opened this issue Oct 29, 2023 · 4 comments
Closed
5 tasks done

No linting error on wrong array types #4807

Malix-Labs opened this issue Oct 29, 2023 · 4 comments
Labels
Issue-Bug A bug to squash. Resolution-Answered Will close automatically.

Comments

@Malix-Labs
Copy link

Malix-Labs commented Oct 29, 2023

Prerequisites

  • I have written a descriptive issue title.
  • I have searched all open and closed issues to ensure it has not already been reported.
  • I have read the troubleshooting guide.
  • I am sure this issue is with the extension itself and does not reproduce in a standalone PowerShell instance.
  • I have verified that I am using the latest version of Visual Studio Code and the PowerShell extension.

Summary

No linting error on wrong array types

PowerShell Version

Name                           Value
----                           -----
PSVersion                      7.3.9
PSEdition                      Core
GitCommitId                    7.3.9
OS                             Microsoft Windows 10.0.22635
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visual Studio Code Version

1.83.1
f1b07bd25dfad64b0167beb15359ae573aecd2cc
x64

Extension Version

Steps to Reproduce

[string[]]$stringArray = @(
	1
	2
)

$stringArray += 2

Visuals

No problems have been detected on the workspace.

@Malix-Labs Malix-Labs added the Issue-Bug A bug to squash. label Oct 29, 2023
@SydneyhSmith
Copy link
Collaborator

Thanks @Malix-off this is actually correct as to how PowerShell works...if you want a custom rule about this check out PSScriptAnalyzer

@SydneyhSmith SydneyhSmith added the Resolution-Answered Will close automatically. label Nov 8, 2023
@Malix-Labs
Copy link
Author

@SydneyhSmith:

Thanks @Malix-off this is actually correct as to how PowerShell works...if you want a custom rule about this check out PSScriptAnalyzer

Can you explain?
2 is converted from an int type to a string type in the process?

@github-actions github-actions bot added the Stale label Nov 16, 2023
Copy link
Contributor

This issue has been marked as resolved and has not had any activity for 1 day. It has been closed for housekeeping purposes.

@andyleejordan
Copy link
Member

@Malix-off that is correct, try it out in PowerShell:

@andyjordane318 ~
> [string[]]$myArray = @(1, 2)
@andyjordane318 ~
> $myArray | %{ $_.GetType() }

IsPublic IsSerial Name                                     BaseType
-------- -------- ----                                     --------
True     True     String                                   System.Object
True     True     String                                   System.Object

@andyjordane318 ~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Bug A bug to squash. Resolution-Answered Will close automatically.
Projects
None yet
Development

No branches or pull requests

3 participants