Home Dashboard Directory Help
Search

Set-StrictMode fails on the quasi property Count for scalars and invalidates its usefulness by Roman Kuzmin


Status: 

Active


1
0
Sign in
to vote
Type: Bug
ID: 770111
Opened: 11/5/2012 9:43:09 AM
Access Restriction: Public
0
Workaround(s)
view
0
User(s) can reproduce this bug

Description

test1.ps1 works and returns 1 because $x.Count is valid in PS v3 and equal to 1

    #################################################
    $x = 'foo'
    $x.Count
    #################################################

but test2.ps1 fails

    #################################################
    Set-StrictMode -Version 2
    $x = 'foo'
    $x.Count
    #################################################

with an error

    Property 'Count' cannot be found on this object. Make sure that it exists.

This failure is inconsistent with the new feature "Count is 1 on scalars".
It also invalidates usefulness of such a feature and discourages use of it.
Details
Sign in to post a comment.
Sign in to post a workaround.