PowerShell / PowerShell/PowerShell

Set-Strictmode should not complain about COUNT & LENGTH properties on elements

Open
#2,798 15 comments 14 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue-Discussion KeepOpen WG-Language WG-NeedsReview
Dominant language
C#
Stars
55.5k
Forks
8.5k
Avg merge
1d 2h
Merged PRs (30d)
88

Description

One of the big problems we have had in the language has been not knowing whether the following expression was going to return a single element or an array:

$x = gps $name

We fixed this longstanding problem by masking over the issue allowing elements to be treated as arrays. e.g.

(gps -id 0).count
(gps -id 0).length

When you enable strictmode - it complains about these and it shouldn't.
I'm about to enable strictmode on a large collection of scripts and I'm sure that is going to find lots of these issue and modifying the code is not going to make the code any better - it will just cause a lot of work and reduce my reliability.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No implementation file or test is named. Start by reproducing the reported strictmode behavior for COUNT and LENGTH on a single element, then trace the strictmode property validation; done means those properties work without complaints while strictmode remains enabled.

Written by the indexing model from the issue text.

Assessment

Tech stack
powershell
Domain
cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.