You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Allow AttributeTargets.Field and .Property for type let bindings (#17093)
* Allow AttributeTargets.Field and .Property for type let bindings
* Fixed tests which involved fields+functions
---------
Co-authored-by: Petr <[email protected]>
// Class let bindings are a special case, they can have attributes that target fields and properties, since they might be lifted to those and contain lambdas/functions.
Copy file name to clipboardExpand all lines: tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/AttributeUsage/AttributeUsage.fs
Copy file name to clipboardExpand all lines: tests/FSharp.Compiler.ComponentTests/Conformance/BasicGrammarElements/CustomAttributes/AttributeUsage/E_AttributeTargetIsField02.fs
+18-18
Original file line number
Diff line number
Diff line change
@@ -8,62 +8,62 @@ type FieldOnlyAttribute() =
8
8
inherit Attribute()
9
9
10
10
typeTestClass()=
11
-
[<FieldOnly>]// Should fail
11
+
[<FieldOnly>]// Should succeed (special exception when function can be lifted to a field)
12
12
static letfunc1()="someFunction"
13
13
14
-
[<FieldOnly>]// Should fail
14
+
[<FieldOnly>]// Should succeed (special exception when function can be lifted to a field)
15
15
static let recfunc2()="someFunction"
16
16
17
-
[<FieldOnly>]// Should fail
17
+
[<FieldOnly>]// Should succeed (special exception when function can be lifted to a field)
18
18
static let recfunc3()="someFunction"
19
-
and [<FieldOnly>]fun4()="someFunction"// Should fail
19
+
and [<FieldOnly>]fun4()="someFunction"// Should succeed (special exception when function can be lifted to a field)
20
20
21
-
[<FieldOnly>]// Should fail
21
+
[<FieldOnly>]// Should succeed (special exception when function can be lifted to a field)
22
22
letfunc5()="someFunction"
23
23
24
-
[<FieldOnly>]// Should fail
24
+
[<FieldOnly>]// Should succeed (special exception when function can be lifted to a field)
25
25
letfunc6 a = a +1
26
26
27
-
[<FieldOnly>]// Should fail
27
+
[<FieldOnly>]// Should succeed (special exception when function can be lifted to a field)
28
28
letfunc7(a,b)= a + b
29
29
30
-
[<FieldOnly>]// Should fail
30
+
[<FieldOnly>]// Should succeed (special exception when function can be lifted to a field)
31
31
letfunc8(a:int):int = a +1
32
32
33
-
[<FieldOnly>]// Should fail
33
+
[<FieldOnly>]// Should succeed (special exception when function can be lifted to a field)
34
34
letfunc9 a b =[ a; b ]
35
35
36
-
[<FieldOnly>]// Should fail
36
+
[<FieldOnly>]// Should succeed (special exception when function can be lifted to a field)
37
37
letfunc10=fun x -> x
38
38
39
-
[<FieldOnly>]// Should fail
39
+
[<FieldOnly>]// Should succeed (special exception when function can be lifted to a field)
40
40
letfunc11= id
41
41
42
-
[<FieldOnly>]// Should fail
42
+
[<FieldOnly>]// Should succeed (special exception when function can be lifted to a field)
43
43
let(|Bool|_|)=function"true"-> Some true|"false"-> Some false|_-> None
44
44
45
-
[<FieldOnly>]// Should fail
45
+
[<FieldOnly>]// Should succeed (special exception when function can be lifted to a field)
0 commit comments