-
Notifications
You must be signed in to change notification settings - Fork 8k
Closed
Description
Prerequisites
- Write a descriptive title.
- Make sure you are able to repro it on the latest released version
- Search the existing issues.
- Refer to the FAQ.
- Refer to Differences between Windows PowerShell 5.1 and PowerShell.
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
}- Save the function to a file and dot-source it.
Get-Reboot | % {$_.<TabComplete>
Expected behavior
PowerShell should not crashActual behavior
PowerShell is crashingError details
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)Environment data
Name Value
---- -----
PSVersion 7.6.0-preview-4
PSEdition Core
GitCommitId 7.6.0-preview-4-74-g9ec06ae798c5c8114f1ed4fb63513d69c4a777eb
OS Microsoft Windows 10.0.26100
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0, 5.0, 5.1, 6.0, 7.0}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0Visuals
Metadata
Metadata
Assignees
Labels
No labels
