Skip to content

New syntax for invoking generic methods doesn't support overload reporting when invoked without parentheses #17668

@mklement0

Description

@mklement0

Prerequisites

Steps to reproduce

Invoking a method name without parentheses (without actually calling the method) is a convenient reflection feature in PowerShell; e.g. (42).ToString lists all overloads of the [int] type's .ToString() method.

However, this doesn't work with the new-in-7.3 syntax (see about_Calling_Generic_Methods) for calling generic methods with explicit type arguments (e.g., [Array]::Empty[int]() to create an empty [int[]] array):

[Array]::Empty         # OK without type argument
[Array]::Empty[int]    # !! BROKEN: treats [int] as an *index* expression

Expected behavior

OverloadDefinitions
-------------------
static T[] Empty[T]()

static int[] Empty[int]()

Actual behavior

ParserError: ...
Line |
  51 |  [Array]::Empty[int]
     |                 ~
     | Array index expression is missing or not valid.

Error details

No response

Environment data

PowerShell Core 7.3.0-preview.5

Visuals

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs-TriageThe issue is new and needs to be triaged by a work group.Resolution-No ActivityIssue has had no activity for 6 months or more

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions