Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f729a9d

Browse files
T-GroCopilot
andcommitted
Fix #5795 test: remove incorrect issue reference, add proper negative repros
The test 'Custom attribute used on type and let in rec module' incorrectly referenced issue #5795, but it didn't actually reproduce the issue. Issue #5795 is about attributes on union cases and type parameters within a rec module, which remain unresolved. Changes: - Remove #5795 reference from test that doesn't repro the actual issue - Add two negative tests with exact #5795 repros (union case + type param) documenting that these scenarios still fail with the expected errors - All 13 tests in the module pass Co-authored-by: Copilot <[email protected]>
1 parent ce04c19 commit f729a9d

1 file changed

Lines changed: 33 additions & 2 deletions

File tree

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

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ type T() =
4040
|> typecheck
4141
|> shouldSucceed
4242

43-
// https://github.com/dotnet/fsharp/issues/5795 - Custom attribute used on type and let in rec module
43+
// Custom attribute defined in same rec module used on type and let declarations
4444
[<Fact>]
45-
let ``Custom attribute used on type and let in rec module`` () =
45+
let ``Custom attribute on type and let in rec module`` () =
4646
FSharp """
4747
module rec M
4848
@@ -55,6 +55,37 @@ type CustomAttribute() =
5555
|> typecheck
5656
|> shouldSucceed
5757

58+
// https://github.com/dotnet/fsharp/issues/5795 - attribute on union case in rec module is not yet resolved
59+
[<Fact>]
60+
let ``Issue 5795 - attribute on union case in rec module`` () =
61+
FSharp """
62+
module rec M
63+
64+
type CustomAttribute() =
65+
inherit System.Attribute()
66+
67+
type A = | [<CustomAttribute>] A
68+
"""
69+
|> typecheck
70+
|> shouldFail
71+
|> withDiagnostics
72+
[ Error 1133, Line 7, Col 14, Line 7, Col 29, "No constructors are available for the type 'CustomAttribute'" ]
73+
74+
// https://github.com/dotnet/fsharp/issues/5795 - attribute on type parameter in rec module is not yet resolved
75+
[<Fact>]
76+
let ``Issue 5795 - attribute on type parameter in rec module`` () =
77+
FSharp """
78+
module rec M
79+
80+
type CustomAttribute() =
81+
inherit System.Attribute()
82+
83+
type B<[<CustomAttribute>]'a> = | B of 'a
84+
"""
85+
|> typecheck
86+
|> shouldFail
87+
|> withErrorCode 39
88+
5889
// Nested module case: open inside outer module, attribute on inner module
5990
[<Fact>]
6091
let ``Open inside nested module resolves for attribute on inner module in namespace rec`` () =

0 commit comments

Comments
 (0)