PowerShell / PowerShell/vscode-powershell
Reports Missing closing '}' on a if statement when not all on one line or the { not on the next line with powershell version 5
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 1.9k
- Forks
- 547
- PR merge metrics
- No merged PRs in 30d
Description
Prerequisites
- I have written a descriptive issue title.
- I have searched all open and closed issues to ensure it has not already been reported.
- I have read the troubleshooting guide.
- I am sure this issue is with the extension itself and does not reproduce in a standalone PowerShell instance.
- I have verified that I am using the latest version of Visual Studio Code and the PowerShell extension.
- If this is a security issue, I have read the security issue reporting guidance.
Summary
When running the following simple script:
`$ben = $true
if ($ben) {
Write-Output "ben"
}
`
the extension throws this error:
Missing closing '}' in statement block or type definition.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : MissingEndCurlyBrace
if the script looks like this:
`$ben = $true
if ($ben)
{
Write-Output "ben"
}`
or this:
`$ben = $true
if ($ben) { Write-Output "ben" }
`
it works.
Or if I switch to version 7 of powershell.
PowerShell Version
Name Value
---- -----
PSVersion 5.1.26100.6584
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.26100.6584
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Visual Studio Code Version
1.105.1
x64
Extension Version
ms-vscode.powershell@2025.4.0
Steps to Reproduce
see description
Visuals
No response
Logs
No logs
Log level set to trace:
found these
ms-vscode.powershell.zip
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the three brace layouts in the issue with PowerShell 5.1 through the VS Code extension, then compare the diagnostics with PowerShell 7. The issue is done when the valid multi-line form no longer reports a missing closing brace while the existing working forms remain valid.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- powershell, typescript
- Domain
- developer-experience, devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100