Description
type Fluent() =
member x.ASomething(a: int) = x
member x.BNothing(b: int) = x
member x.CEverything(c: int) = x
let f =
Fluent()
.ASomething(1)
.BNothing(2)
.CEverything(3)
let unchainedFluentOk =
Fluent()
.ASomething (1)
let chainedFluentFail =
Fluent()
.ASomething (1) // FS0003 error here
.BNothing (2) // FS0039 error here
.CEverything (3)
error FS0003: This value is not a function and cannot be applied
error FS0039: The type 'Int32' does not define the field, constructor or member 'BNothing'.
There is a bit of a surprise considering unchainedFluentOk
type checks to Fluent
, not Int32
, and the error message doesn't point at the issue.
Describe the solution you'd like
I'm not sure it can be changed to compile because it is indeed ambiguous, (1)
is same as 1
when it is standing on its own in the code.
Maybe an error message specific to the case of method invocation being chained could improve the situation when facing the error but the user not figuring it is the argument spacing which makes the type checking fail.
Describe alternatives you've considered
Finding a way that would make it work, which is backward compatible, and doesn't introduce surprises in other contexts.
Maybe that requires boxing an ambiguity in the AST, which gets resolved during type checking, I'm not sure that is a good idea though.
Additional context
Metadata
Metadata
Assignees
Labels
Type
Projects
Status