Skip to content

Commit 6cd4d59

Browse files
authored
Enable EnforceAttributeTargets for F# 9.0 (dotnet#17558)
* Fix 17514: dotnet#17514 * LoaderOptimization thingy
1 parent 6a9747e commit 6cd4d59

File tree

7 files changed

+26
-4
lines changed

7 files changed

+26
-4
lines changed

docs/release-notes/.FSharp.Compiler.Service/9.0.100.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
* Allow access modifies to auto properties getters and setters ([Language suggestion #430](https://github.com/fsharp/fslang-suggestions/issues/430), [PR 16687](https://github.com/dotnet/fsharp/pull/16687), [PR 16861](https://github.com/dotnet/fsharp/pull/16861), [PR 17522](https://github.com/dotnet/fsharp/pull/17522))
2323
* Render C# nullable-analysis attributes in tooltips ([PR #17485](https://github.com/dotnet/fsharp/pull/17485))
2424
* Allow object expression without overrides. ([Language suggestion #632](https://github.com/fsharp/fslang-suggestions/issues/632), [PR #17387](https://github.com/dotnet/fsharp/pull/17387))
25+
* Enable FSharp 9.0 Language Version ([Issue #17497](https://github.com/dotnet/fsharp/issues/17438)), [PR](https://github.com/dotnet/fsharp/pull/17500)))
26+
* Enable LanguageFeature.EnforceAttributeTargets in F# 9.0. ([Issue #17514](https://github.com/dotnet/fsharp/issues/17558), [PR #17516](https://github.com/dotnet/fsharp/pull/17558))
2527

2628
### Changed
2729

@@ -32,6 +34,5 @@
3234
* Enforce `AttributeTargets` on unions. ([PR #17389](https://github.com/dotnet/fsharp/pull/17389))
3335
* Applied nullable reference types to FSharp.Compiler.Service itself ([PR #15310](https://github.com/dotnet/fsharp/pull/15310))
3436
* Ensure that isinteractive multi-emit backing fields are not public. ([Issue #17439](https://github.com/dotnet/fsharp/issues/17438)), ([PR #17439](https://github.com/dotnet/fsharp/pull/17439))
35-
* Enable FSharp 9.0 Language Version ([Issue #17497](https://github.com/dotnet/fsharp/issues/17438)), [PR](https://github.com/dotnet/fsharp/pull/17500)))
3637
* Better error reporting for unions with duplicated fields. ([PR #17521](https://github.com/dotnet/fsharp/pull/17521))
3738
### Breaking Changes

src/Compiler/Checking/Expressions/CheckExpressions.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11087,7 +11087,7 @@ and TcNormalizedBinding declKind (cenv: cenv) env tpenv overallTy safeThisValOpt
1108711087
errorR(Error(FSComp.SR.tcLiteralCannotHaveGenericParameters(), mBinding))
1108811088

1108911089
if g.langVersion.SupportsFeature(LanguageFeature.EnforceAttributeTargets) && memberFlagsOpt.IsNone && not attrs.IsEmpty then
11090-
TcAttributeTargetsOnLetBindings cenv env attrs overallPatTy overallExprTy (not declaredTypars.IsEmpty) isClassLetBinding
11090+
TcAttributeTargetsOnLetBindings { cenv with tcSink = TcResultsSink.NoSink } env attrs overallPatTy overallExprTy (not declaredTypars.IsEmpty) isClassLetBinding
1109111091

1109211092
CheckedBindingInfo(inlineFlag, valAttribs, xmlDoc, tcPatPhase2, explicitTyparInfo, nameToPrelimValSchemeMap, rhsExprChecked, argAndRetAttribs, overallPatTy, mBinding, debugPoint, isCompGen, literalValue, isFixed), tpenv
1109311093

src/Compiler/Facilities/LanguageFeatures.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,10 +212,10 @@ type LanguageVersion(versionText) =
212212
LanguageFeature.LowerSimpleMappingsInComprehensionsToFastLoops, languageVersion90
213213
LanguageFeature.ParsedHashDirectiveArgumentNonQuotes, languageVersion90
214214
LanguageFeature.EmptyBodiedComputationExpressions, languageVersion90
215+
LanguageFeature.EnforceAttributeTargets, languageVersion90
215216

216217
// F# preview
217218
LanguageFeature.UnmanagedConstraintCsharpInterop, previewVersion // not enabled because: https://github.com/dotnet/fsharp/issues/17509
218-
LanguageFeature.EnforceAttributeTargets, previewVersion // not enabled because: https://github.com/dotnet/fsharp/issues/17514
219219
LanguageFeature.FromEndSlicing, previewVersion // Unfinished features --- needs work
220220
LanguageFeature.AllowAccessModifiersToAutoPropertiesGettersAndSetters, previewVersion
221221
LanguageFeature.AllowObjectExpressionWithoutOverrides, previewVersion

tests/fsharp/core/attributes/test.fsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ open System.Diagnostics
4242
[<LoaderOptimization(LoaderOptimization.MultiDomainHost)>]
4343
#endif
4444

45-
let main = ()
45+
let main () = ()
4646

4747

4848
(* attribute on a type *)

tests/fsharp/typecheck/sigs/neg06.bsl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,18 @@
22
neg06.fs(3,40,3,45): typecheck error FS0039: The type 'Encoding' does not define the field, constructor or member 'Ascii'. Maybe you want one of the following:
33
ASCII
44

5+
neg06.fs(11,3,11,9): typecheck error FS0842: This attribute is not valid for use on this language element
6+
57
neg06.fs(12,6,12,31): typecheck error FS0942: Struct types are always sealed
68

9+
neg06.fs(17,3,17,9): typecheck error FS0842: This attribute is not valid for use on this language element
10+
711
neg06.fs(18,6,18,24): typecheck error FS0948: Interface types cannot be sealed
812

913
neg06.fs(24,6,24,30): typecheck error FS0944: Abbreviated types cannot be given the 'Sealed' attribute
1014

15+
neg06.fs(26,3,26,9): typecheck error FS0842: This attribute is not valid for use on this language element
16+
1117
neg06.fs(27,6,27,33): typecheck error FS0942: Delegate types are always sealed
1218

1319
neg06.fs(31,9,31,29): typecheck error FS0945: Cannot inherit a sealed type
@@ -88,14 +94,20 @@ neg06.fs(223,13,223,21): typecheck error FS0800: Invalid use of a type name
8894

8995
neg06.fs(300,10,300,12): typecheck error FS0009: Uses of this construct may result in the generation of unverifiable .NET IL code. This warning can be disabled using '--nowarn:9' or '#nowarn "9"'.
9096

97+
neg06.fs(303,7,303,104): typecheck error FS0842: This attribute is not valid for use on this language element
98+
9199
neg06.fs(304,10,304,12): typecheck error FS0937: Only structs and classes without primary constructors may be given the 'StructLayout' attribute
92100

93101
neg06.fs(310,10,310,12): typecheck error FS0937: Only structs and classes without primary constructors may be given the 'StructLayout' attribute
94102

95103
neg06.fs(314,10,314,12): typecheck error FS0937: Only structs and classes without primary constructors may be given the 'StructLayout' attribute
96104

105+
neg06.fs(316,7,316,104): typecheck error FS0842: This attribute is not valid for use on this language element
106+
97107
neg06.fs(317,10,317,12): typecheck error FS0937: Only structs and classes without primary constructors may be given the 'StructLayout' attribute
98108

109+
neg06.fs(319,7,319,104): typecheck error FS0842: This attribute is not valid for use on this language element
110+
99111
neg06.fs(320,10,320,12): typecheck error FS0937: Only structs and classes without primary constructors may be given the 'StructLayout' attribute
100112

101113
neg06.fs(326,10,326,18): typecheck error FS0954: This type definition involves an immediate cyclic reference through a struct field or inheritance relation
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
neg110.fs(5,3,5,15): typecheck error FS1133: No constructors are available for the type 'NotAttribute'
12

23
neg110.fs(5,3,5,15): typecheck error FS3242: This type does not inherit Attribute, it will not work correctly with other .NET languages.

tests/fsharp/typecheck/sigs/neg16.bsl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,20 @@ neg16.fs(7,13,7,16): typecheck error FS0644: Namespaces cannot contain extension
33

44
neg16.fs(23,10,23,11): typecheck error FS0935: Types with the 'AllowNullLiteral' attribute may only inherit from or implement types which also allow the use of the null literal
55

6+
neg16.fs(34,7,34,23): typecheck error FS0842: This attribute is not valid for use on this language element
7+
68
neg16.fs(35,10,35,11): typecheck error FS0934: Records, union, abbreviations and struct types cannot have the 'AllowNullLiteral' attribute
79

810
neg16.fs(38,10,38,11): typecheck error FS0934: Records, union, abbreviations and struct types cannot have the 'AllowNullLiteral' attribute
911

1012
neg16.fs(41,10,41,11): typecheck error FS0934: Records, union, abbreviations and struct types cannot have the 'AllowNullLiteral' attribute
1113

14+
neg16.fs(43,7,43,23): typecheck error FS0842: This attribute is not valid for use on this language element
15+
1216
neg16.fs(44,10,44,11): typecheck error FS0934: Records, union, abbreviations and struct types cannot have the 'AllowNullLiteral' attribute
1317

18+
neg16.fs(46,7,46,23): typecheck error FS0842: This attribute is not valid for use on this language element
19+
1420
neg16.fs(47,10,47,13): typecheck error FS0934: Records, union, abbreviations and struct types cannot have the 'AllowNullLiteral' attribute
1521

1622
neg16.fs(49,7,49,23): typecheck error FS0842: This attribute is not valid for use on this language element
@@ -73,6 +79,8 @@ neg16.fs(90,7,90,22): typecheck error FS0025: Incomplete pattern matches on this
7379

7480
neg16.fs(96,3,97,16): typecheck error FS0823: The 'VolatileField' attribute may only be used on 'let' bindings in classes
7581

82+
neg16.fs(99,5,99,18): typecheck error FS0842: This attribute is not valid for use on this language element
83+
7684
neg16.fs(99,3,100,14): typecheck error FS0823: The 'VolatileField' attribute may only be used on 'let' bindings in classes
7785

7886
neg16.fs(99,3,100,14): typecheck error FS0879: Volatile fields must be marked 'mutable' and cannot be thread-static

0 commit comments

Comments
 (0)