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 end
Reproducible 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.
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:
Reproducible in both F# 4.1 and 4.0.
Expected behavior
Compilation should fail. Compare with C#
which fails with the error
This issue actually caused runtime issues for me, because I accidentally inserted a wrong type in attribute annotations.