Repository navigation
Closed
Labels
Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aResolution-No ActivityIssue has had no activity for 6 months or moreWG-Enginecore PowerShell engine, interpreter, and runtime
Description
Steps to reproduce
class Test {
[bool] Equals([Test] $other) {
return $true
}
}Expected behavior
No exception, type is defined successfully.
Actual behavior
PS> class Test { [bool] Equals([Test] $other) { return $true } }
An error occurred while creating the pipeline.
+ CategoryInfo : NotSpecified: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : RuntimeException
PS> $Error[0].GetBaseException() | Format-List * -Force
Message : Type must be a type provided by the runtime. (Parameter 'types')
ParamName : types
TargetSite : System.Reflection.MethodBase SelectMethod(System.Reflection.BindingFlags, System.Reflection.MethodBase[], System.Type[],
System.Reflection.ParameterModifier[])
StackTrace : at System.DefaultBinder.SelectMethod(BindingFlags bindingAttr, MethodBase[] match, Type[] types, ParameterModifier[]
modifiers)
at System.RuntimeType.GetMethodImplCommon(String name, Int32 genericParameterCount, BindingFlags bindingAttr, Binder
binder, CallingConventions callConv, Type[] types, ParameterModifier[] modifiers)
at System.RuntimeType.GetMethodImpl(String name, BindingFlags bindingAttr, Binder binder, CallingConventions callConv,
Type[] types, ParameterModifier[] modifiers)
at System.Type.GetMethod(String name, BindingFlags bindingAttr, Binder binder, CallingConventions callConvention,
Type[] types, ParameterModifier[] modifiers)
at System.Type.GetMethod(String name, Type[] types)
at System.Management.Automation.Language.TypeDefiner.DefineTypeHelper.MethodExistsOnBaseClassAndFinal(String
methodName, Type[] parameterTypes)
at System.Management.Automation.Language.TypeDefiner.DefineTypeHelper.DefineMethod(FunctionMemberAst functionMemberAst)
at System.Management.Automation.Language.TypeDefiner.DefineTypeHelper.DefineMembers()
at System.Management.Automation.Language.TypeDefiner.DefineTypes(Parser parser, Ast rootAst, TypeDefinitionAst[]
typeDefinitions)
at System.Management.Automation.Language.Compiler.DefinePowerShellTypes(Ast rootForDefiningTypes, TypeDefinitionAst[]
typeAsts)
at System.Management.Automation.Language.Compiler.GenerateTypesAndUsings(ScriptBlockAst rootForDefiningTypesAndUsings,
List`1 exprs)
at System.Management.Automation.Language.Compiler.CompileSingleLambda(ReadOnlyCollection`1 statements,
ReadOnlyCollection`1 traps, String funcName, IScriptExtent entryExtent, IScriptExtent exitExtent, ScriptBlockAst
rootForDefiningTypesAndUsings)
at System.Management.Automation.Language.Compiler.CompileNamedBlock(NamedBlockAst namedBlockAst, String funcName,
ScriptBlockAst rootForDefiningTypes)
at System.Management.Automation.Language.Compiler.VisitScriptBlock(ScriptBlockAst scriptBlockAst)
at System.Management.Automation.Language.Compiler.Compile(CompiledScriptBlockData scriptBlock, Boolean optimize)
at System.Management.Automation.CompiledScriptBlockData.ReallyCompile(Boolean optimize)
at System.Management.Automation.CompiledScriptBlockData.CompileUnoptimized()
at System.Management.Automation.CompiledScriptBlockData.Compile(Boolean optimized)
at System.Management.Automation.DlrScriptCommandProcessor.Init()
at System.Management.Automation.DlrScriptCommandProcessor..ctor(ScriptBlock scriptBlock, ExecutionContext context,
Boolean useNewScope, CommandOrigin origin, SessionStateInternal sessionState, Object dollarUnderbar)
at System.Management.Automation.Runspaces.Command.CreateCommandProcessor(ExecutionContext executionContext, Boolean
addToHistory, CommandOrigin origin)
at System.Management.Automation.Runspaces.LocalPipeline.CreatePipelineProcessor()
Data : {}
InnerException :
HelpLink :
Source : System.Private.CoreLib
HResult : -2147024809Environment data
Name Value
---- -----
PSVersion 7.0.0-preview.4
PSEdition Core
GitCommitId 7.0.0-preview.4
OS Microsoft Windows 10.0.18362
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
This also occurs in Core 6.2.3 but does not occur in Windows PowerShell.
Reacted by Michael Klement and Chris Kuech
Metadata
Metadata
Assignees
Labels
Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aResolution-No ActivityIssue has had no activity for 6 months or moreWG-Enginecore PowerShell engine, interpreter, and runtime
Activity
iSazonov commentedon Sep 25, 2019
It seems we already discussed an issue like this. PowerShell should compile a type before it can use it. So any recursion in type definition (direct or indirect) is impossible.
SeeminglyScience commentedon Sep 25, 2019
Ilya (@iSazonov) It works when the method isn't an override candidate. For example, the same snippet works if you change the method name
EqualstoEquals2:Basically
DefineTypeHelper.MethodExistsOnBaseClassAndFinalshould return early if the parameter types contain the type currently being defined.microsoft-github-policy-service commentedon Nov 16, 2023
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
microsoft-github-policy-service commentedon Nov 16, 2023
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
microsoft-github-policy-service commentedon Nov 16, 2023
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
microsoft-github-policy-service commentedon Nov 23, 2023
This issue has been marked as "No Activity" as there has been no activity for 6 months. It has been closed for housekeeping purposes.