-
Notifications
You must be signed in to change notification settings - Fork 833
Description
What
The following code leads to the following error:
let bar foo =
let age = foo.Bar + 99
age * 2Lookup on object of indeterminate type based on information prior to this program point. A type annotation may be needed prior to this program point to constrain the type of the object. This may allow the lookup to be resolved.
Why
The message is overly verbose and complicated, using words like "indeterminate" and so on. In reality, all we're trying to say is: "I couldn't infer what this type is! Please add an annotation to tell me directly.". We could also provide some guidance to explain that the compiler cannot generally infer types from C#.
How
How about:
Unable to infer the type of
foo. Please add a type annotation wherefoois declared e.g. (foo:string).
or
It is unclear what type
foois. Please add a type annotation wherefoois declared e.g. (foo:string).
We could also add some "background" information as well:
Unable to infer the type of
foo. Please add a type annotation wherefoois declared e.g. (foo:string). F# can only directly infer from member usage types that are defined in F#; if the type offoois defined in a C# library (including anything from the Base Class Library e.g. string), F# will not be able to infer it based on a member access.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status