-
Notifications
You must be signed in to change notification settings - Fork 830
Description
Related #5475.
What
The following code gives an error message which could be improved upon.
let arg = " foo "
printfn "%s" arg.Trim()The current error message states:
error FS0597: Successive arguments should be separated by spaces or tupled, and arguments involving function or method applications should be parenthesized
Why
The actual error message contains the answer, but it is not easy to understand, especially for beginners to F# that don't understand why this is a problem. Worse still, if you put a space between arg.Trim and (), you get two different errors:
- The IDE will give the error:
error FS0002: This function takes too many arguments, or is used in a context where a function is not expected - Executing the entire expression in FSI will give the error:
error FS0001: Type mismatch. Expecting a 'string -> 'a -> 'b' but given a 'string -> unit' The type ''a -> 'b' does not match the type 'unit'
How
I wouldn't propose initially looking at the second issue raised above (introducing a space) but would suggest rewording the initial message to something like this:
error FS0597: Incompatible arguments. If you are passing a value to a function, that is itself a function call, ensure that it is wrapped in parentheses. For example, consider rewriting 'foo bar()' as 'foo (bar())'.
I'm not sure under what other conditions this error is shown so it might need to be modified.
Successive arguments should be separated by spaces or tupled, and arguments involving function or method applications should be parenthesized`
Metadata
Metadata
Assignees
Labels
Type
Projects
Status