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
|
c9f9eb2 to
929e77c
Compare
|
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? |
819c8be to
73cfbce
Compare
…ent types Previously, using an array of a user-defined type as a custom attribute argument (e.g. [<DefaultValue([||] : A[])>]) caused an internal error FS0192 in encodeCustomAttrElemType. The ECMA 335 metadata format requires the array element type to be encoded even for empty arrays, and only primitive types, enums, string, System.Type, and System.Object are valid. This change adds a validation check in GenAttribArg (IlxGen.fs) that detects unsupported element types before reaching the IL writer, and reports a proper diagnostic (FS3885) instead of crashing. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…e instead of erroring Empty arrays of user-defined types in custom attributes (e.g. [<DefaultValue([||] : A[])>]) no longer produce FS3885. Since no elements need encoding, System.Object is used as the element type. Non-empty arrays of unencodable types still error correctly. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The bootstrap compiler needs an explicit type annotation on the 'g' parameter in GenAttribArg to resolve g.ilg.typ_Object, since g's type is not constrained until later match cases (TypeOfExpr, EnumExpr, etc.). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
a5a1e73 to
a0a1a5d
Compare
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
@copilot : See my comment above. Research implementation changes needed to support empty arrays as default values, and develop using TDD (via ComponentTests. Since this is IL specific, make sure to use "compileAndRun" and also use the helper for "ilverify" of the compiled code in that test. |
Fixes #12796
Adds a regression test verifying that
[<DefaultValue(null)>]on a record field of typeA[]compiles successfully without internal error FS0192.