Skip to content

Commit d11ff7e

Browse files
T-GroCopilot
andcommitted
Add negative test for FS3885 non-empty invalid array in attribute
Verify that non-empty arrays of user-defined types in custom attributes produce the proper FS3885 diagnostic instead of an internal error. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent a530e0f commit d11ff7e

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

tests/FSharp.Compiler.ComponentTests/Language/AttributeCheckingTests.fs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,28 @@ type C() = class end
190190
|> compile
191191
|> shouldSucceed
192192

193+
// https://github.com/dotnet/fsharp/issues/12796
194+
// Non-empty arrays of user-defined types in custom attributes should produce FS3885 diagnostic.
195+
// Previously this caused FS0192 internal error in encodeCustomAttrElemType.
196+
[<Fact>]
197+
let ``Issue 12796 - Non-empty array of user-defined type in attribute gives proper error`` () =
198+
FSharp
199+
"""
200+
module TestModule
201+
202+
open System.ComponentModel
203+
204+
[<AllowNullLiteral>]
205+
type A() = class end
206+
207+
[<DefaultValue([| (null : A) |])>]
208+
type B() = class end
209+
"""
210+
|> compile
211+
|> shouldFail
212+
|> withErrorCode 3885
213+
|> withDiagnosticMessageMatches "not a valid custom attribute argument type"
214+
193215
// https://github.com/dotnet/fsharp/issues/12796
194216
// Empty arrays of user-defined types in custom attributes should compile successfully.
195217
// The element type is substituted with System.Object since no elements need encoding.

0 commit comments

Comments
 (0)