Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
06d9a57
Enforce AttributeTargets.Class and AttributeTargets.Struct
edgarfgp Feb 29, 2024
f938cdd
Enforce AttributeTargets.Class properly in the compiler
edgarfgp Feb 29, 2024
923da3d
Enforce AttributeTargets.Class properly in the compiler
edgarfgp Feb 29, 2024
693da5e
update tests
edgarfgp Mar 1, 2024
83a60d8
Fix test
edgarfgp Mar 1, 2024
504d7e3
release-notes
edgarfgp Mar 1, 2024
868a637
Merge branch 'main' into fix-13526
edgarfgp Mar 1, 2024
456102b
Merge branch 'main' into fix-13526
edgarfgp Mar 1, 2024
8330a1e
Merge branch 'main' into fix-13526
edgarfgp Mar 1, 2024
5d8e88a
Merge branch 'main' into fix-13526
edgarfgp Mar 2, 2024
14266e2
Merge branch 'main' into fix-13526
edgarfgp Mar 4, 2024
f77abc3
Merge branch 'main' into fix-13526
edgarfgp Mar 5, 2024
3a373ec
Merge branch 'main' into fix-13526
edgarfgp Mar 5, 2024
c5efc37
Merge branch 'main' into fix-13526
edgarfgp Mar 5, 2024
5a04a29
Merge branch 'main' into fix-13526
KevinRansom Mar 6, 2024
4cf61c8
Merge branch 'main' into fix-13526
edgarfgp Mar 6, 2024
884827a
Extend AutoOpenAttribute and RequireQualifiedAccessAttribute to use A…
edgarfgp Mar 6, 2024
bcd2f1f
Put back AutoOpen and RequireQualifiedAccess
edgarfgp Mar 6, 2024
f708384
Update tests
edgarfgp Mar 6, 2024
74973f5
Merge branch 'main' into fix-13526
edgarfgp Mar 6, 2024
51a6d10
Release notes
edgarfgp Mar 6, 2024
d2033ca
Merge branch 'fix-13526' of github.com:edgarfgp/fsharp into fix-13526
edgarfgp Mar 6, 2024
fee8e76
Merge branch 'main' into fix-13526
edgarfgp Mar 6, 2024
83d91ab
Merge branch 'main' into fix-13526
edgarfgp Mar 7, 2024
eb6b654
Merge branch 'main' into fix-13526
edgarfgp Mar 7, 2024
67ae66e
Merge branch 'main' into fix-13526
edgarfgp Mar 7, 2024
ffbe939
Merge branch 'main' into fix-13526
edgarfgp Mar 8, 2024
0deaa4d
release notes
edgarfgp Mar 8, 2024
22c5614
Merge branch 'main' into fix-13526
edgarfgp Mar 11, 2024
db5ccee
Extend attributes targets
vzarytovskii Mar 11, 2024
7c98bac
Update prim-types.fs
vzarytovskii Mar 11, 2024
6dc1845
Merge branch 'main' into fix-13526
vzarytovskii Mar 11, 2024
da86375
Merge branch 'main' into fix-13526
edgarfgp Mar 12, 2024
78a5dfd
Merge branch 'main' into fix-13526
edgarfgp Mar 12, 2024
c404ce4
Merge branch 'main' into fix-13526
edgarfgp Mar 13, 2024
ca45332
Update 8.0.300.md
psfinaki Mar 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/release-notes/.FSharp.Compiler.Service/8.0.300.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* Enforce AttributeTargets on let values and functions. ([PR #16692](https://github.com/dotnet/fsharp/pull/16692))
* Enforce AttributeTargets on union case declarations. ([PR #16764](https://github.com/dotnet/fsharp/pull/16764))
* Disallow using base to invoke an abstract base method. ([Issue #13926](https://github.com/dotnet/fsharp/issues/13926), [PR #16773](https://github.com/dotnet/fsharp/pull/16773))
* Enforce AttributeTargets on structs and classes ([PR #16790](https://github.com/dotnet/fsharp/pull/16790))
* Parser: fix pattern range for idents with trivia ([PR #16824](https://github.com/dotnet/fsharp/pull/16824))
* Fix broken code completion after a record type declaration ([PR #16813](https://github.com/dotnet/fsharp/pull/16813))

Expand Down
1 change: 1 addition & 0 deletions docs/release-notes/.FSharp.Core/8.0.300.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
### Fixed

* Preserve original stack traces in resumable state machines generated code if available. ([PR #16568](https://github.com/dotnet/fsharp/pull/16568))
* Enforce AttributeTargets on structs and classes. Also update `RequireQualifiedAccessAttribute` and `AutoOpenAttribute` to use `AttributeTargets.Struct` ([PR #16790](https://github.com/dotnet/fsharp/pull/16790))
1 change: 1 addition & 0 deletions docs/release-notes/.Language/preview.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* Allow extension methods without type attribute work for types from imported assemblies. ([PR #16368](https://github.com/dotnet/fsharp/pull/16368))
* Enforce AttributeTargets on let values and functions. ([PR #16692](https://github.com/dotnet/fsharp/pull/16692))
* Enforce AttributeTargets on union case declarations. ([PR #16764](https://github.com/dotnet/fsharp/pull/16764))
* Enforce AttributeTargets on structs and classes ([PR #16790](https://github.com/dotnet/fsharp/pull/16790))

### Changed

Expand Down
10 changes: 8 additions & 2 deletions src/Compiler/Checking/CheckDeclarations.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2926,10 +2926,16 @@ module EstablishTypeDefinitionCores =
| _ ->
let kind =
match kind with
| SynTypeDefnKind.Class -> TFSharpClass
| SynTypeDefnKind.Class ->
if g.langVersion.SupportsFeature(LanguageFeature.EnforceAttributeTargetsOnStructAndClasses) then
TcAttributesWithPossibleTargets false cenv envinner AttributeTargets.Class synAttrs |> ignore
TFSharpClass
| SynTypeDefnKind.Interface -> TFSharpInterface
| SynTypeDefnKind.Delegate _ -> TFSharpDelegate (MakeSlotSig("Invoke", g.unit_ty, [], [], [], None))
| SynTypeDefnKind.Struct -> TFSharpStruct
| SynTypeDefnKind.Struct ->
if g.langVersion.SupportsFeature(LanguageFeature.EnforceAttributeTargetsOnStructAndClasses) then
TcAttributesWithPossibleTargets false cenv envinner AttributeTargets.Struct synAttrs |> ignore
TFSharpStruct
| _ -> error(InternalError("should have inferred tycon kind", m))

TFSharpTyconRepr (Construct.NewEmptyFSharpTyconData kind)
Expand Down
1 change: 1 addition & 0 deletions src/Compiler/FSComp.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1596,6 +1596,7 @@ featureBooleanReturningAndReturnTypeDirectedPartialActivePattern,"Boolean-return
featureEnforceAttributeTargetsOnFunctions,"Enforce AttributeTargets on functions"
featureEnforceAttributeTargetsUnionCaseDeclarations,"Enforce AttributeTargets on union case declarations"
featureLowerInterpolatedStringToConcat,"Optimizes interpolated strings in certain cases, by lowering to concatenation"
featureEnforceAttributeTargetsOnStructAndClasses,"Enforce AttributeTargets on structs and classes"
featureLowerIntegralRangesToFastLoops,"Optimizes certain uses of the integral range (..) and range-step (.. ..) operators to fast while-loops."
3354,tcNotAFunctionButIndexerNamedIndexingNotYetEnabled,"This value supports indexing, e.g. '%s.[index]'. The syntax '%s[index]' requires /langversion:preview. See https://aka.ms/fsharp-index-notation."
3354,tcNotAFunctionButIndexerIndexingNotYetEnabled,"This expression supports indexing, e.g. 'expr.[index]'. The syntax 'expr[index]' requires /langversion:preview. See https://aka.ms/fsharp-index-notation."
Expand Down
3 changes: 3 additions & 0 deletions src/Compiler/Facilities/LanguageFeatures.fs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ type LanguageFeature =
| EnforceAttributeTargetsOnFunctions
| EnforceAttributeTargetsUnionCaseDeclarations
| LowerInterpolatedStringToConcat
| EnforceAttributeTargetsOnStructAndClasses
| LowerIntegralRangesToFastLoops

/// LanguageVersion management
Expand Down Expand Up @@ -204,6 +205,7 @@ type LanguageVersion(versionText) =
LanguageFeature.EnforceAttributeTargetsOnFunctions, previewVersion
LanguageFeature.EnforceAttributeTargetsUnionCaseDeclarations, previewVersion
LanguageFeature.LowerInterpolatedStringToConcat, previewVersion
LanguageFeature.EnforceAttributeTargetsOnStructAndClasses, previewVersion
LanguageFeature.LowerIntegralRangesToFastLoops, previewVersion
]

Expand Down Expand Up @@ -351,6 +353,7 @@ type LanguageVersion(versionText) =
| LanguageFeature.EnforceAttributeTargetsOnFunctions -> FSComp.SR.featureEnforceAttributeTargetsOnFunctions ()
| LanguageFeature.EnforceAttributeTargetsUnionCaseDeclarations -> FSComp.SR.featureEnforceAttributeTargetsUnionCaseDeclarations ()
| LanguageFeature.LowerInterpolatedStringToConcat -> FSComp.SR.featureLowerInterpolatedStringToConcat ()
| LanguageFeature.EnforceAttributeTargetsOnStructAndClasses -> FSComp.SR.featureEnforceAttributeTargetsOnStructAndClasses ()
| LanguageFeature.LowerIntegralRangesToFastLoops -> FSComp.SR.featureLowerIntegralRangesToFastLoops ()

/// Get a version string associated with the given feature.
Expand Down
1 change: 1 addition & 0 deletions src/Compiler/Facilities/LanguageFeatures.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ type LanguageFeature =
| EnforceAttributeTargetsOnFunctions
| EnforceAttributeTargetsUnionCaseDeclarations
| LowerInterpolatedStringToConcat
| EnforceAttributeTargetsOnStructAndClasses
| LowerIntegralRangesToFastLoops

/// LanguageVersion management
Expand Down
5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.cs.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.de.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.es.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.fr.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.it.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.ja.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.ko.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.pl.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.pt-BR.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.ru.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.tr.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.zh-Hans.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.zh-Hant.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/FSharp.Core/fslib-extra-pervasives.fs
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ type MeasureOne =
class
end

[<AttributeUsage(AttributeTargets.Class, AllowMultiple = false)>]
[<AttributeUsage(AttributeTargets.Class ||| AttributeTargets.Struct, AllowMultiple = false)>]
type TypeProviderAttribute() =
inherit System.Attribute()

Expand Down
2 changes: 1 addition & 1 deletion src/FSharp.Core/fslib-extra-pervasives.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ namespace Microsoft.FSharp.Core.CompilerServices
type MeasureOne

/// <summary>Place on a class that implements ITypeProvider to extend the compiler</summary>
[<AttributeUsageAttribute(AttributeTargets.Class, AllowMultiple = false)>]
[<AttributeUsageAttribute(AttributeTargets.Class ||| AttributeTargets.Struct, AllowMultiple = false)>]
type TypeProviderAttribute =
inherit System.Attribute

Expand Down
18 changes: 9 additions & 9 deletions src/FSharp.Core/prim-types.fs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ namespace Microsoft.FSharp.Core
type CLIMutableAttribute() =
inherit Attribute()

[<AttributeUsage (AttributeTargets.Class, AllowMultiple=false)>]
[<AttributeUsage (AttributeTargets.Class ||| AttributeTargets.Struct , AllowMultiple=false)>]
[<Sealed>]
type AutoSerializableAttribute(value:bool) =
inherit Attribute()
Expand All @@ -127,19 +127,19 @@ namespace Microsoft.FSharp.Core
type ReferenceEqualityAttribute() =
inherit Attribute()

[<AttributeUsage (AttributeTargets.Class, AllowMultiple=false)>]
[<AttributeUsage (AttributeTargets.Class ||| AttributeTargets.Struct, AllowMultiple=false)>]
[<Sealed>]
type StructuralComparisonAttribute() =
inherit Attribute()

[<AttributeUsage (AttributeTargets.Class, AllowMultiple=false)>]
[<AttributeUsage (AttributeTargets.Class ||| AttributeTargets.Struct, AllowMultiple=false)>]
[<Sealed>]
type StructuralEqualityAttribute() =
inherit Attribute()

[<AttributeUsage (AttributeTargets.Class ||| AttributeTargets.Interface |||
AttributeTargets.Delegate ||| AttributeTargets.Struct |||
AttributeTargets.Enum, AllowMultiple=false)>]
AttributeTargets.Enum, AllowMultiple=false)>]
[<Sealed>]
type NoEqualityAttribute() =
inherit Attribute()
Expand All @@ -161,9 +161,9 @@ namespace Microsoft.FSharp.Core
type NoComparisonAttribute() =
inherit Attribute()

[<AttributeUsage (AttributeTargets.Class ||| AttributeTargets.Parameter |||
AttributeTargets.Method ||| AttributeTargets.Property |||
AttributeTargets.Constructor, AllowMultiple=false)>]
[<AttributeUsage (AttributeTargets.Class ||| AttributeTargets.Struct |||
AttributeTargets.Parameter ||| AttributeTargets.Method |||
AttributeTargets.Property ||| AttributeTargets.Constructor, AllowMultiple=false)>]
[<Sealed>]
type ReflectedDefinitionAttribute(includeValue: bool) =
inherit Attribute()
Expand Down Expand Up @@ -350,12 +350,12 @@ namespace Microsoft.FSharp.Core
type RequiresExplicitTypeArgumentsAttribute() =
inherit Attribute()

[<AttributeUsage(AttributeTargets.Class, AllowMultiple=false)>]
[<AttributeUsage(AttributeTargets.Class ||| AttributeTargets.Struct, AllowMultiple=false)>]
[<Sealed>]
type RequireQualifiedAccessAttribute() =
inherit Attribute()

[<AttributeUsage (AttributeTargets.Class ||| AttributeTargets.Assembly, AllowMultiple=true)>]
[<AttributeUsage (AttributeTargets.Class ||| AttributeTargets.Struct ||| AttributeTargets.Assembly, AllowMultiple=true)>]
[<Sealed>]
type AutoOpenAttribute(path:string) =
inherit Attribute()
Expand Down
Loading