Skip to content

Can't paste a comment (#) after a pipe (|) and a newline  #18022

Open
@iRon7

Description

Prerequisites

Steps to reproduce

Paste the following 3 lines into PowerShell (same for Windows PowerShell and VS Code):

1..3 |
# I do 't expect an error here
ForEach-Object { $_ }

Expected behavior

No errors, the commented line (# ...) to be neglected.
Similar to putting the comment directly after the pipe character:

1..3 | # I don 't expect an error here
ForEach-Object { $_ }

Actual behavior

Error

Error details

>> # I don 't expect an error here
ParserError:
Line |
   1 |  1..3 |
     |        ~
     | An empty pipe element is not allowed.

Environment data

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

Visuals

2022-09-03_19h55_01

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions