Skip to content

Commit cffc9bf

Browse files
authored
Regression test for #14304 (#17839)
1 parent 2109d5d commit cffc9bf

File tree

1 file changed

+33
-0
lines changed
  • tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/AttributeUsage

1 file changed

+33
-0
lines changed

tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/AttributeUsage/AttributeUsage.fs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -933,3 +933,36 @@ and [<ApplicationTenantJsonDerivedType>]
933933
|> verifyCompile
934934
|> shouldSucceed
935935
#endif
936+
937+
[<Fact>] // Regression for https://github.com/dotnet/fsharp/issues/14304
938+
let ``Construct an object with default and params parameters using parameterless constructor`` () =
939+
Fsx """
940+
open System
941+
open System.Runtime.InteropServices
942+
943+
type DefaultAndParams([<Optional; DefaultParameterValue(1)>]x: int, [<ParamArray>] value: string[]) =
944+
inherit Attribute()
945+
946+
type ParamsOnly([<ParamArray>] value: string[]) =
947+
inherit Attribute()
948+
949+
type DefaultOnly([<Optional; DefaultParameterValue(1)>]x: int) =
950+
inherit Attribute()
951+
952+
[<DefaultAndParams>]
953+
type Q1 = struct end
954+
955+
[<DefaultAndParams(x = 1)>] // ok
956+
type Q11 = struct end
957+
958+
[<DefaultAndParams(value = [||])>] // ok
959+
type Q12 = struct end
960+
961+
[<ParamsOnly>]
962+
type Q2 = struct end
963+
964+
[<DefaultOnly>]
965+
type Q3 = struct end
966+
"""
967+
|> typecheck
968+
|> shouldSucceed

0 commit comments

Comments
 (0)