Skip to content

Error with class parsing #3083

@iSazonov

Description

@iSazonov

The code below is failed with PSReadLine loaded. Without PSReadLine the code is succeeed.
It is the parser issue not PSReadLine PowerShell/PSReadLine#500 (comment)

This is a bug in the parser - it should be throwing an IncompleteParseException instead of a ParseException .

Steps to reproduce

Copy-Paste the code:

class foo
{
    [void]q() { $a=1 }

    [string]$bar
}

Expected behavior

Pass parsing without errors.

Actual behavior

PS C:\> class foo
>>> {
>>>     [void]q() { $a=1 }
>>>
At line:3 char:5
+     [void]q() { $a=1 }
+     ~~~~~~~~~~~~~~~~~~
Missing closing '}' in statement block or type definition.
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : MissingEndCurlyBrace

PS C:\>     [string]$bar

PS C:\> }
At line:1 char:1
+ }
+ ~
Unexpected token '}' in expression or statement.
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : UnexpectedToken

Environment data
----------------

<!-- provide the output of $PSVersionTable -->

```powershell
> $PSVersionTable
Name                           Value
----                           -----
PSVersion                      5.0.10240.17146
WSManStackVersion              3.0
SerializationVersion           1.1.0.1
CLRVersion                     4.0.30319.42000
BuildVersion                   10.0.10011.16384
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion      2.3

Name                           Value
----                           -----
CLRVersion
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
GitCommitId                    v6.0.0-alpha.14-61-gfe3d01627a0e7a1a7882d880299ed9e2cb88c97e-dirty
BuildVersion                   3.0.0.0
PSVersion                      6.0.0-alpha
PSRemotingProtocolVersion      2.3
WSManStackVersion              3.0
SerializationVersion           1.1.0.1
PSEdition                      Core

Metadata

Metadata

Assignees

Labels

Resolution-FixedThe issue is fixed.WG-Enginecore PowerShell engine, interpreter, and runtimeWG-Languageparser, language semantics

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions