Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion src/Compiler/Checking/AttributeChecking.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
1 change: 1 addition & 0 deletions src/Compiler/Checking/CheckDeclarations.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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 _
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,9 @@ C.Update()
|> withDiagnostics [
(Error 101, Line 9, Col 1, Line 9, Col 9, "This construct is deprecated. Use B instead")
]

[<Fact>]
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

Expand All @@ -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")
]

[<Fact>]
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

Expand All @@ -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")
]

[<Fact>]
let ``Obsolete attribute warning is taken into account when used on an enum field and invocation`` () =
Fsx """
open System

type Color =
| [<Obsolete("Use B instead")>] 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")
]

[<Fact>]
let ``Obsolete attribute is taken into account when used on an type and use extension method`` () =
Expand Down