-
Couldn't load subscription status.
- Fork 833
Closed
Labels
Area-Compiler-CheckingType checking, attributes and all aspects of logic checkingType checking, attributes and all aspects of logic checkingBugImpact-Low(Internal MS Team use only) Describes an issue with limited impact on existing code.(Internal MS Team use only) Describes an issue with limited impact on existing code.
Milestone
Description
While browsing stackoverflow for something unrelated, I found an old mention of some compiler error.
(ref https://stackoverflow.com/questions/24884814/serializing-f-discriminated-unions-with-protobuf)
open System
[<AttributeUsage(AttributeTargets.Method)>]
type MethodLevelAttribute() =
inherit Attribute()
[<AttributeUsage(AttributeTargets.Property ||| AttributeTargets.Field)>]
type PropertyOrFieldLevelAttribute() =
inherit Attribute()
// correctly fails
//[<MethodLevelAttribute>]
//type SomeType() = class end
type SomeUnion =
| [<PropertyOrFieldLevelAttribute>] Case1 of int
| [<PropertyOrFieldLevelAttribute>] Case2 of string
module Program =
[<EntryPoint>]
let main argv =
printfn "%A" argv
0 // return an integer exit code
Expected:
Compiler Error
Actual:
The compiler stuck the attributes to the static construction methods:
Version:
<package id="FSharp.Compiler.Tools" version="4.1.17" targetFramework="net452" />
(also repros with current nightly)
Note:
I only checked this one case, there may be other cases where it is also not correctly checked.
BoundedChenn31
Metadata
Metadata
Assignees
Labels
Area-Compiler-CheckingType checking, attributes and all aspects of logic checkingType checking, attributes and all aspects of logic checkingBugImpact-Low(Internal MS Team use only) Describes an issue with limited impact on existing code.(Internal MS Team use only) Describes an issue with limited impact on existing code.
Type
Projects
Status
Done
