Skip to content

Improve error reporting: missing cast operator for subtype case #1128

@smoothdeveloper

Description

@smoothdeveloper

Related to #1103 #1127

What

let foo () : IDictionary<'a,'b> = Dictionary<'a,'b>()

Error: This expression was expected to have type IDictionary<'a,'b> but here has type Dictionary<'a,'b>.

Why

New commers don't know about need for upcast, nor they know the idiomatic

let foo () : IDictionary<'a,'b> = Dictionary<'a,'b>() :> _

How

Error: This expression was expected to have type IDictionary<'a,'b> but here has type Dictionary<'a,'b>, consider using cast operator :> _.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Feature ImprovementTheme-Simple-F#A cross-community initiative called "Simple F#", keeping people in the sweet spot of the language.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions