Fsharp: Cannot use attribute on inferred binding type

Created on 4 Dec 2018  路  2Comments  路  Source: dotnet/fsharp

According to F# 4.1 spec, 13.1 Custom Attributes, the following attribute placement is possible

let foo a: [<SomeAttribute>] = a + 5

but it cannot be parsed with neither F# 4.1 nor F# 4.5 FCS/fsi. Specifying binding return type explicitly makes it parseable.

let foo: [<Attr>] = 12

  let foo: [<Attr>] = 12
  ------------------^

stdin(3,19): error FS0010: Unexpected symbol '=' in binding

let foo: [<Attr>] int = 12
val foo : int = 12
Area-Docs Resolution-By Design

Most helpful comment

This also compile
f# let foo a: [<SomeAttribute>] _ = a + 5

All 2 comments

This also compile
f# let foo a: [<SomeAttribute>] _ = a + 5

Yes this is by design, the spec needs clarification

Was this page helpful?
0 / 5 - 0 ratings