Can't paste a comment (#
) after a pipe (|
) and a newline #18022
Open
Description
Prerequisites
- Write a descriptive title.
- Make sure you are able to repro it on the latest released version
- Search the existing issues.
- Refer to the FAQ.
- Refer to Differences between Windows PowerShell 5.1 and PowerShell.
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