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
…pe argument (fixes #8353) Handle Const.Zero for all primitive value types in GenAttribArg, which is used when [<Optional>] is specified without [<DefaultParameterValue>] on attribute constructor parameters. Previously only System.Object, System.String, and System.Type were handled, causing an internal error for bool, int, and other value types. Co-authored-by: T-Gro <46543583+T-Gro@users.noreply.github.com> Agent-Logs-Url: https://github.com/dotnet/fsharp/sessions/6f81842d-a307-4b7e-9ef2-ffa78948f9c6
…onal attribute args Co-authored-by: T-Gro <46543583+T-Gro@users.noreply.github.com> Agent-Logs-Url: https://github.com/dotnet/fsharp/sessions/6f81842d-a307-4b7e-9ef2-ffa78948f9c6
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
…error-custom-attribute
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.