-
Notifications
You must be signed in to change notification settings - Fork 833
Closed
Labels
BugImpact-Medium(Internal MS Team use only) Describes an issue with moderate impact on existing code.(Internal MS Team use only) Describes an issue with moderate impact on existing code.
Milestone
Description
I just came across an interesting behaviour, in which the F# compiler only requires a type to have a parameterless constructor in order to be accepted as an attribute annotation.
Repro steps
The following code compiles without issue:
type Foo () = class end
[<Foo>] type Bar = class endReproducible in both F# 4.1 and 4.0.
Expected behavior
Compilation should fail. Compare with C#
public class Foo
{
public Foo() { }
}
[Foo]
public class Bar { }which fails with the error
error CS0616: 'Foo' is not an attribute class
This issue actually caused runtime issues for me, because I accidentally inserted a wrong type in attribute annotations.
Metadata
Metadata
Assignees
Labels
BugImpact-Medium(Internal MS Team use only) Describes an issue with moderate impact on existing code.(Internal MS Team use only) Describes an issue with moderate impact on existing code.