Handle Const.Zero for primitive value types in custom attribute codegen#19484
Open
Handle Const.Zero for primitive value types in custom attribute codegen#19484
Conversation
Copilot
AI
changed the title
[WIP] Fix internal error when using custom attribute without optional argument
Handle Const.Zero for primitive value types in custom attribute codegen
Mar 24, 2026
T-Gro
approved these changes
Mar 26, 2026
Contributor
❗ Release notes required
|
12 tasks
744f543 to
4fee713
Compare
…pe argument (#8353) GenAttribArg in IlxGen.fs handles Const.Zero (the default for [<Optional>] params without [<DefaultParameterValue>]) for System.Object, System.String, and System.Type, but not for primitive value types. This causes an internal error (FS0073) when applying an attribute with an [<Optional>] value type parameter and no default. Add Const.Zero -> default value mappings for all 12 primitive types valid in custom attributes: bool, sbyte, int16, int32, int64, byte, uint16, uint32, uint64, single, double, char. Fixes #8353 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
4fee713 to
73500fb
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
GenAttribArginIlxGen.fshandlesConst.Zero(the default for[<Optional>]params without[<DefaultParameterValue>]) forSystem.Object,System.String, andSystem.Type, but not for primitive value types. This causes an internal error for code like:Changes
Const.Zero→ default value mappings for all 12 primitive types valid in custom attributes:bool,sbyte,int16,int32,int64,byte,uint16,uint32,uint64,single,double,char[<Optional>]attribute constructor params for all primitive value typesOriginal prompt
⚡ Quickly spin up Copilot coding agent tasks from anywhere on your macOS or Windows machine with Raycast.