Repository navigation
Reject unsupported numeric literals in class attributes - #28598
Alex Ritter (Calexr4403) wants to merge 1 commit into
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
|
Alex Ritter (@Calexr4403) please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
4 similar comments
|
Alex Ritter (@Calexr4403) please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
|
Alex Ritter (@Calexr4403) please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
|
Alex Ritter (@Calexr4403) please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
|
Alex Ritter (@Calexr4403) please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
There was a problem hiding this comment.
🟡 Changes recommended
The parser rejects valid attribute arguments before supported conversions occur; validation should inspect converted values, with positive regression tests covering those conversions.
1 open issue
What changed in this PR
This PR moves unsupported numeric class-attribute arguments from runtime emission failures to parser errors.
Changes:
- Rejects Decimal and BigInteger literals during class-attribute constant checks.
- Adds regression cases for decimal, BigInteger, and oversized integer literals.
| File | Description |
|---|---|
| test/powershell/Language/Classes/Scripting.Classes.BasicParsing.Tests.ps1 | Adds parser-error regression tests. |
| src/System.Management.Automation/engine/parser/ConstantValues.cs | Rejects unsupported numeric literal types in class attributes. |
Review effort: Balanced
| if (CheckingClassAttributeArguments && | ||
| (constantExpressionAst.Value is decimal || constantExpressionAst.Value is System.Numerics.BigInteger)) | ||
| { | ||
| return false; |

PR Summary
Report a parser error for Decimal and BigInteger literals in class attribute arguments, rather than a runtime failure when emitting the .NET custom attribute.
PR Context
.NET custom attributes cannot encode
System.DecimalorSystem.Numerics.BigIntegerarguments. The class-attribute constant check now rejects those literal values; ordinary function attribute behavior is unchanged.Fixes #27772
PR Checklist
.csand.ps1files have the required copyright headers