Skip to content

PSReadLine throws an exception when typing a type name after using namespace [NameSpace] #17113

@MatejKafka

Description

@MatejKafka

Exception report

### Environment
PSReadLine: 2.2.2
PowerShell: 7.3.0-preview.2
OS: Microsoft Windows 10.0.19044
BufferWidth: 208
BufferHeight: 46

Last 5 Keys:

 UpArrow UpArrow Enter
 [ e

### Exception

System.Management.Automation.PSArgumentException: Cannot process argument because the value of argument "name" is not valid. Change the value of the "name" argument and run the operation again.
   at System.Management.Automation.Language.TypeName..ctor(IScriptExtent extent, String name)
   at System.Management.Automation.Language.TypeResolver.ResolveTypeNameWithContext(TypeName typeName, Exception& exception, Assembly[] assemblies, TypeResolutionState typeResolutionState)
   at System.Management.Automation.Language.SymbolResolver.VisitTypeName(TypeName typeName, Int32 genericArgumentCount, Boolean isAttribute)
   at System.Management.Automation.Language.SymbolResolver.DispatchTypeName(ITypeName type, Int32 genericArgumentCount, Boolean isAttribute)
   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

image

Steps to reproduce

$> using namespace [NameSpace]
$> [A ...

The namespace doesn't have to exist, just make up anything. The important part are the brackets around the namespace – they shouldn't be there, but apparently it is syntactically valid (not sure about semantics) and causes PSReadLine to crash.

Metadata

Metadata

Assignees

No one assigned

    Labels

    In-PRIndicates that a PR is out for the issueIssue-BugIssue has been identified as a bug in the productWG-Enginecore PowerShell engine, interpreter, and runtime

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions