diff --git a/src/Compiler/Checking/AttributeChecking.fs b/src/Compiler/Checking/AttributeChecking.fs index d1d50393523..82f504865ab 100644 --- a/src/Compiler/Checking/AttributeChecking.fs +++ b/src/Compiler/Checking/AttributeChecking.fs @@ -507,7 +507,8 @@ let CheckUnionCaseAttributes g (x:UnionCaseRef) m = /// Check the attributes on a record field, returning errors and warnings as data. let CheckRecdFieldAttributes g (x:RecdFieldRef) m = CheckEntityAttributes g x.TyconRef m ++ (fun () -> - CheckFSharpAttributes g x.PropertyAttribs m) + CheckFSharpAttributes g x.PropertyAttribs m) ++ (fun () -> + CheckFSharpAttributes g x.RecdField.FieldAttribs m) /// Check the attributes on an F# value, returning errors and warnings as data. let CheckValAttributes g (x:ValRef) m = diff --git a/src/Compiler/Checking/CheckDeclarations.fs b/src/Compiler/Checking/CheckDeclarations.fs index 1081998708b..ac0080ca829 100644 --- a/src/Compiler/Checking/CheckDeclarations.fs +++ b/src/Compiler/Checking/CheckDeclarations.fs @@ -545,6 +545,7 @@ module TcRecdUnionAndEnumDeclarations = let TcEnumDecl cenv env parent thisTy fieldTy (SynEnumCase(attributes=Attributes synAttrs; ident= SynIdent(id,_); value=v; xmlDoc=xmldoc; range=m)) = let attrs = TcAttributes cenv env AttributeTargets.Field synAttrs + match v with | SynConst.Bytes _ | SynConst.UInt16s _ diff --git a/tests/FSharp.Compiler.ComponentTests/Language/ObsoleteAttributeCheckingTests.fs b/tests/FSharp.Compiler.ComponentTests/Language/ObsoleteAttributeCheckingTests.fs index c2fa57509fc..29ea071835f 100644 --- a/tests/FSharp.Compiler.ComponentTests/Language/ObsoleteAttributeCheckingTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/Language/ObsoleteAttributeCheckingTests.fs @@ -206,9 +206,9 @@ C.Update() |> withDiagnostics [ (Error 101, Line 9, Col 1, Line 9, Col 9, "This construct is deprecated. Use B instead") ] - + [] - let ``Obsolete attribute is taken into account when used on an enum and invocation`` () = + let ``Obsolete attribute error is taken into account when used on an enum and invocation`` () = Fsx """ open System @@ -219,15 +219,14 @@ type Color = let c = Color.Red """ - |> ignoreWarnings |> compile |> shouldFail |> withDiagnostics [ (Error 101, Line 9, Col 9, Line 9, Col 14, "This construct is deprecated. Use B instead") ] - + [] - let ``Obsolete attribute is taken into account when used on an enum entry and invocation`` () = + let ``Obsolete attribute error is taken into account when used on an enum field and invocation`` () = Fsx """ open System @@ -237,9 +236,28 @@ type Color = let c = Color.Red """ - |> ignoreWarnings |> compile - |> shouldSucceed + |> shouldFail + |> withDiagnostics [ + (Error 101, Line 8, Col 9, Line 8, Col 18, "This construct is deprecated. Use B instead") + ] + + [] + let ``Obsolete attribute warning is taken into account when used on an enum field and invocation`` () = + Fsx """ +open System + +type Color = + | [] Red = 0 + | Green = 1 + +let c = Color.Red + """ + |> compile + |> shouldFail + |> withDiagnostics [ + (Warning 44, Line 8, Col 9, Line 8, Col 18, "This construct is deprecated. Use B instead") + ] [] let ``Obsolete attribute is taken into account when used on an type and use extension method`` () =