This is stripped-down function that allows for successful repro of PowerShell crash on tab completion:
PowerShell should not crash
at System.Management.Automation.TypeInferenceVisitor.InferTypeFrom(System.Management.Automation.Language.VariableExpressionAst, System.Collections.Generic.List`1<System.Management.Automation.PSTypeName>)
at System.Management.Automation.TypeInferenceVisitor.System.Management.Automation.Language.ICustomAstVisitor.VisitVariableExpression(System.Management.Automation.Language.VariableExpressionAst)
at System.Management.Automation.TypeInferenceVisitor.GetExpressionType(System.Management.Automation.Language.ExpressionAst, Boolean)
at System.Management.Automation.TypeInferenceVisitor.InferTypesFrom(System.Management.Automation.Language.MemberExpressionAst)
at System.Management.Automation.TypeInferenceVisitor.InferTypeFrom(System.Management.Automation.Language.VariableExpressionAst, System.Collections.Generic.List`1<System.Management.Automation.PSTypeName>)
at System.Management.Automation.TypeInferenceVisitor.System.Management.Automation.Language.ICustomAstVisitor.VisitVariableExpression(System.Management.Automation.Language.VariableExpressionAst)
at System.Management.Automation.TypeInferenceVisitor.InferTypesFromPreviousCommand(System.Management.Automation.Language.CommandAst, System.Collections.Generic.List`1<System.Management.Automation.PSTypeName>)
at System.Management.Automation.TypeInferenceVisitor.InferTypesFromObjectCmdlets(System.Management.Automation.Language.CommandAst, System.Management.Automation.CmdletInfo, System.Management.Automation.Language.PseudoBindingInfo)
at System.Management.Automation.TypeInferenceVisitor.InferTypesFrom(System.Management.Automation.Language.CommandAst, System.Collections.Generic.List`1<System.Management.Automation.PSTypeName>, Boolean)
at System.Management.Automation.TypeInferenceVisitor.System.Management.Automation.Language.ICustomAstVisitor.VisitCommand(System.Management.Automation.Language.CommandAst)
at System.Management.Automation.TypeInferenceVisitor.InferTypesFromSelectCommand(System.Management.Automation.Language.PseudoBindingInfo, System.Management.Automation.Language.CommandAst, System.Collections.Generic.List`1<System.Management.Automation.PSTypeName>)
at System.Management.Automation.TypeInferenceVisitor.InferTypesFromObjectCmdlets(System.Management.Automation.Language.CommandAst, System.Management.Automation.CmdletInfo, System.Management.Automation.Language.PseudoBindingInfo)
at System.Management.Automation.TypeInferenceVisitor.InferTypesFrom(System.Management.Automation.Language.CommandAst, System.Collections.Generic.List`1<System.Management.Automation.PSTypeName>, Boolean)
at System.Management.Automation.TypeInferenceVisitor.System.Management.Automation.Language.ICustomAstVisitor.VisitCommand(System.Management.Automation.Language.CommandAst)
at System.Management.Automation.TypeInferenceVisitor.System.Management.Automation.Language.ICustomAstVisitor.VisitNamedBlock(System.Management.Automation.Language.NamedBlockAst)
at System.Management.Automation.TypeInferenceVisitor.System.Management.Automation.Language.ICustomAstVisitor.VisitScriptBlock(System.Management.Automation.Language.ScriptBlockAst)
at System.Management.Automation.TypeInferenceVisitor.InferTypesFrom(System.Management.Automation.Language.CommandAst, System.Collections.Generic.List`1<System.Management.Automation.PSTypeName>, Boolean)
at System.Management.Automation.TypeInferenceVisitor.System.Management.Automation.Language.ICustomAstVisitor.VisitCommand(System.Management.Automation.Language.CommandAst)
at System.Management.Automation.TypeInferenceVisitor.InferTypeFrom(System.Management.Automation.Language.VariableExpressionAst, System.Collections.Generic.List`1<System.Management.Automation.PSTypeName>)
at System.Management.Automation.TypeInferenceVisitor.System.Management.Automation.Language.ICustomAstVisitor.VisitVariableExpression(System.Management.Automation.Language.VariableExpressionAst)
at System.Management.Automation.AstTypeInference.InferTypeOf(System.Management.Automation.Language.Ast, System.Management.Automation.TypeInferenceContext, System.Management.Automation.TypeInferenceRuntimePermissions)
at System.Management.Automation.CompletionCompleters.CompleteMember(System.Management.Automation.CompletionContext, Boolean, Int32 ByRef)
at System.Management.Automation.CompletionAnalysis.GetResultHelper(System.Management.Automation.CompletionContext, Int32 ByRef, Int32 ByRef)
at System.Management.Automation.CompletionAnalysis.GetResults(System.Management.Automation.PowerShell, Int32 ByRef, Int32 ByRef)
at System.Management.Automation.CommandCompletion.CompleteInputImpl(System.Management.Automation.Language.Ast, System.Management.Automation.Language.Token[], System.Management.Automation.Language.IScriptPosition, System.Collections.Hashtable)
at DynamicClass.CallSite.Target(System.Runtime.CompilerServices.Closure, System.Runtime.CompilerServices.CallSite, System.Type, System.String, Int32, System.Collections.Hashtable)
at System.Management.Automation.Interpreter.DynamicInstruction`5[[System.__Canon, System.Private.CoreLib, Version=10.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.__Canon, System.Private.CoreLib, Version=10.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.Int32, System.Private.CoreLib, Version=10.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.__Canon, System.Private.CoreLib, Version=10.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.__Canon, System.Private.CoreLib, Version=10.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].Run(System.Management.Automation.Interpreter.InterpretedFrame)
at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(System.Management.Automation.Interpreter.InterpretedFrame)
at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(System.Management.Automation.Interpreter.InterpretedFrame)
at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(System.Management.Automation.Interpreter.InterpretedFrame)
at System.Management.Automation.Interpreter.Interpreter.Run(System.Management.Automation.Interpreter.InterpretedFrame)
at System.Management.Automation.Interpreter.LightLambda.RunVoid1[[System.__Canon, System.Private.CoreLib, Version=10.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]](System.__Canon)
at System.Management.Automation.PSScriptCmdlet.RunClause(System.Action`1<System.Management.Automation.Language.FunctionContext>, System.Object, System.Object)
at System.Management.Automation.CommandProcessorBase.Complete()
at System.Management.Automation.CommandProcessorBase.DoComplete()
at System.Management.Automation.Internal.PipelineProcessor.DoCompleteCore(System.Management.Automation.CommandProcessorBase)
at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(System.Object)
at System.Management.Automation.Runspaces.LocalPipeline.InvokeHelper()
at System.Management.Automation.Runspaces.LocalPipeline.InvokeThreadProc()
at System.Management.Automation.Runspaces.PipelineThread.WorkerProc()
at System.Threading.Thread+StartHelper.Callback(System.Object)
at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
Prerequisites
Steps to reproduce
This is stripped-down function that allows for successful repro of PowerShell crash on tab completion:
enum Reboot {Pending; Unneeded} function Get-Reboot { [CmdletBinding()] param( [Reboot]$Reboot ) $status = @{} $data = @( @{Name='Server1'; Status='Pending'}, @{Name='Server2'; Status='Unneeded'} ) $data.ForEach{ $status.Add($_.Name, $_.Status) } switch ($Reboot) { 'Pending' { $data = $data.Where{ $status[$_.Name] -eq 'Pending' } break } 'Unneeded' { $data = $data.Where{ $status[$_.Name] -eq 'Unneeded' } break } } $data | Sort-Object -Property Name | Select-Object -ExpandProperty Name }Get-Reboot | % {$_.<TabComplete>Expected behavior
PowerShell should not crashActual behavior
PowerShell is crashingError details
Environment data
Visuals