Add regression test: #12796, DefaultValue null on array type record field#19472
Add regression test: #12796, DefaultValue null on array type record field#19472
Conversation
|
| open System.ComponentModel | ||
|
|
||
| type A = { AField: string } | ||
| type B = { [<DefaultValue(null)>] BField: A[] } |
There was a problem hiding this comment.
Big NO, the issue really says:
[<DefaultValue([||] : A[])>]
|
Commit pushed:
|
This comment has been minimized.
This comment has been minimized.
|
Commit pushed:
|
|
🤖 This is an automated response from Regression PR Shepherd. This regression test proves the bug in #12796 still exists on Desktop .NET Framework. Closing this PR is recommended. The bug: The test: The failure: The cc
|
f367e8f to
254f0a8
Compare
…d field Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Per reviewer feedback, use the exact syntax from the issue report: [<DefaultValue([||] : A[])>] rather than [<DefaultValue(null)>]. The empty-array-cast form is the specific repro that triggered the 'encodeCustomAttrElemType: unrecognized custom element type' error. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The internal error FS0192 is caught during type-checking; using typecheck is sufficient and faster than a full compile. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The test for [<DefaultValue([||] : A[])>] triggers FS0192 internal error in encodeCustomAttrElemType on Desktop .NET Framework during attribute encoding. The bug is fixed on CoreCLR only. Use FactForNETCOREAPP to skip the test on Desktop where the bug still exists. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ent types Replace FS0192 internal error (encodeCustomAttrElemType crash) with a proper user-facing diagnostic (FS3885) when a custom attribute array argument has an element type that cannot be encoded in CLI metadata per ECMA 335. Only primitive types, enums, string, System.Type, and System.Object are valid element types for arrays in custom attributes. User-defined types like records or classes now produce a clear error instead of an internal compiler crash. The validation is added in GenAttribArg (IlxGen.fs) before the attribute encoding layer is reached, so the error is caught early with proper source location information. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
c9f9eb2 to
929e77c
Compare
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
I don't get why we would have problems encoding empty arrays of any type? It does not matter if we cannot store instances of that type, since it is empty. If we can store a string array, an empty string array, why also not an arbitrary empty array? |
Fixes #12796
Adds a regression test verifying that
[<DefaultValue(null)>]on a record field of typeA[]compiles successfully without internal error FS0192.