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 moreUp-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsWG-Enginecore PowerShell engine, interpreter, and runtimeWG-ReviewedA Working Group has reviewed this and made a recommendation
Description
Steps to reproduce
# Parameterless constructor isn't the best example since you can't
# do that in C# either, but it also repros with parameters.
class Test : ValueType {
Test() { }
}
[Test]::new()Expected behavior
Either
- Parse error when
ValueTypeis the base class - Special handling for value types when generating constructors. I'm guessing this has to do with
$thisneeding to be explicitly boxed, but I haven't looked into it
Actual behavior
Internal CLR error. (0x80131506)
at DynamicClass.Test(System.Runtime.CompilerServices.Closure, System.Management.Automation.Language.FunctionContext)
at System.Management.Automation.ScriptBlock.InvokeWithPipeImpl(System.Management.Automation.ScriptBlockClauseToInvoke, Boolean, System.Collections.Generic.Dictionary`2<System.String,System.Management.Automation.ScriptBlock>, System.Collections.Generic.List`1<System.Management.Automation.PSVariable>, ErrorHandlingBehavior, System.Object, System.Object, System.Object, System.Management.Automation.Internal.Pipe, System.Management.Automation.InvocationInfo, System.Object[])
at System.Management.Automation.ScriptBlock.InvokeWithPipe(Boolean, ErrorHandlingBehavior, System.Object, System.Object, System.Object, System.Management.Automation.Internal.Pipe, System.Management.Automation.InvocationInfo, Boolean, System.Collections.Generic.List`1<System.Management.Automation.PSVariable>, System.Collections.Generic.Dictionary`2<System.String,System.Management.Automation.ScriptBlock>, System.Object[])
at System.Management.Automation.ScriptBlock.InvokeAsMemberFunction(System.Object, System.Object[])
at System.Management.Automation.Internal.ScriptBlockMemberMethodWrapper.InvokeHelper(System.Object, System.Object, System.Object[])
at System.RuntimeTypeHandle.CreateInstance(System.RuntimeType, Boolean, Boolean, Boolean ByRef, System.RuntimeMethodHandleInternal ByRef, Boolean ByRef)
at System.RuntimeType.CreateInstanceDefaultCtorSlow(Boolean, Boolean, Boolean)
at System.RuntimeType.CreateInstanceDefaultCtor(Boolean, Boolean, Boolean, Boolean)
at System.Activator.CreateInstance(System.Type, Boolean, Boolean)
at System.Activator.CreateInstance(System.Type)
at System.Management.Automation.Interpreter.InitializeLocalInstruction+MutableValue.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=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]](System.__Canon)
The above stack trace minus the first two lines repeats for about 5,000 lines before PowerShell crashes. Sometimes the stack trace isn't included, and it's just the first line.
Environment data
Name Value
---- -----
PSVersion 7.0.0-preview.2
PSEdition Core
GitCommitId 7.0.0-preview.2
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
Reacted by Michael Klement and Mikey Lombardi (He/Him)
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 moreUp-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsWG-Enginecore PowerShell engine, interpreter, and runtimeWG-ReviewedA Working Group has reviewed this and made a recommendation
Activity
iSazonov commentedon Jan 31, 2020
/cc Rob Holt (@rjmholt) for your class issue collection.
vexx32 commentedon Jun 2, 2022
Marking for triage so the Engine WG can pick it up.
IISResetMe commentedon Jul 21, 2022
Engine WG reviewed this issue, and agree the current behavior is less than ideal.
Given no immediate plans exist to introduce support for emitting value types, we should actively prevent
System.ValueTypefrom being used as a base class and instead emit a more helpful error at parse-time ("Subclassing ValueType is not supported" or similar).mklement0 commentedon Dec 29, 2024
This issue should be labeled
Keep-Openand possibly alsoUp-for-Grabsmicrosoft-github-policy-service commentedon Aug 15, 2025
This issue has not had any activity in 6 months, if there is no further activity in 7 days, the issue will be closed automatically.
Activity in this case refers only to comments on the issue. If the issue is closed and you are the author, you can re-open the issue using the button below. Please add more information to be considered during retriage. If you are not the author but the issue is impacting you after it has been closed, please submit a new issue with updated details and a link to this issue and the original.