Skip to content

Writing the type signature of a hugely dimensional array causes PSReadline to throw #2923

Closed

Description

@HumanEquivalentUnit

Prerequisites

  • Write a descriptive title.
  • Make sure you are able to repro it on the latest released version
  • Search the existing issues, especially the pinned issues.

Exception report

PS C:\> [int[,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
Oops, something went wrong.
Please report this bug with ALL the details below, including both the 'Environment' and 'Exception' sections.
Please report on GitHub: https://github.com/PowerShell/PSReadLine/issues/new?template=Bug_Report.md
Thank you!

### Environment
PSReadLine: 2.2.0-beta3
PowerShell: 7.1.5
OS: Microsoft Windows 10.0.19042
BufferWidth: 130
BufferHeight: 39

Last 37 Keys

 [ i n t [ , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,

Exception

System.TypeLoadException: 'System.Int32[,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,]' from assembly 'System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' has too many dimensions.
   at System.RuntimeTypeHandle.MakeArray(Int32 rank)
   at System.RuntimeType.MakeArrayType(Int32 rank)
   at System.Management.Automation.Language.ArrayTypeName.GetReflectionType()
   at System.Management.Automation.Language.SymbolResolver.VisitArrayTypeName(ArrayTypeName arrayTypeName)
   at System.Management.Automation.Language.SymbolResolver.VisitTypeExpression(TypeExpressionAst typeExpressionAst)
   at System.Management.Automation.Language.TypeExpressionAst.InternalVisit(AstVisitor visitor)
   at System.Management.Automation.Language.CommandExpressionAst.InternalVisit(AstVisitor visitor)
   at System.Management.Automation.Language.PipelineAst.InternalVisit(AstVisitor visitor)
   at System.Management.Automation.Language.StatementBlockAst.InternalVisit(AstVisitor visitor, ReadOnlyCollection`1 traps, ReadOnlyCollection`1 statements, AstVisitAction action)
   at System.Management.Automation.Language.NamedBlockAst.InternalVisit(AstVisitor visitor)
   at System.Management.Automation.Language.ScriptBlockAst.InternalVisit(AstVisitor visitor)
   at System.Management.Automation.Language.Ast.Visit(AstVisitor astVisitor)
   at System.Management.Automation.Language.SymbolResolver.ResolveSymbols(Parser parser, ScriptBlockAst scriptBlockAst)
   at System.Management.Automation.Language.ScriptBlockAst.PerformPostParseChecks(Parser parser)
   at System.Management.Automation.Language.Parser.ParseTask(String fileName, String input, List`1 tokenList, Boolean recursed, ParseMode parseMode)
   at System.Management.Automation.Language.Parser.Parse(String fileName, String input, List`1 tokenList, ParseError[]& errors, ParseMode parseMode)
   at System.Management.Automation.Language.Parser.ParseInput(String input, String fileName, Token[]& tokens, ParseError[]& errors)

Screenshot

N/A

Environment data

PS Version: 7.1.5
PS HostName: ConsoleHost (Windows Terminal)
PSReadLine Version: 2.2.0-beta3
PSReadLine EditMode: Windows
OS: 10.0.19041.1 (WinBuild.160101.0800)
BufferWidth: 130
BufferHeight: 39

Steps to reproduce

Open a new PowerShell, type [int[,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, and on the last comma or one past that, an exception appears; there's no need to press Enter, close the type signature, trigger autocomplete suggestions, it happens while writing.

Expected behavior

The same behaviour as typing [asdf or any other non-existent type; no exception.

Actual behavior

The above exception happens.

Related weird errors if you do copy and paste a line with more commas (a couple of times to get past this exception), then instead of the normal "Unable to find type" exception when you run the line, there is a ParentContainsErrorRecordException and the line is not added to the history:

PS C:\> [int[,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,]]::new()
ParentContainsErrorRecordException: An error occurred while creating the pipeline.

# compare with:
PS C:\> [asdf]::new()
InvalidOperation: Unable to find type [asdf].

Activity

  1. ghost added
    Needs-Triage 🔍
    on Oct 16, 2021
  2. iSazonov commented on Oct 18, 2021

    @iSazonov

    I think it should be fixed in PowerShell repo.

    /cc Rain Sallow (/u/ta11ow) (@vexx32)

  3. vexx32 commented on Oct 18, 2021

    @vexx32

    I'm not really sure what a fix for this would be. Do we just pretend there's a parse error after a certain number of commas? 🤔

  4. iSazonov commented on Oct 18, 2021

    @iSazonov

    I guess Parser doesn't return right error so that PSReadline report this correctly.

  5. vexx32 commented on Oct 18, 2021

    @vexx32

    I'm unsure if this is a parse-time error currently, but going off the .NET error there we probably should add an explicit parse error for it.

  6. daxian-dbw commented on Oct 19, 2021

    @daxian-dbw
    Member

    This is a powershell parser bug. I opened PowerShell/PowerShell#16275 to track the issue in PowerShell repo.

  7. ghost removed
    Needs-Triage 🔍
    on Oct 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions