Skip to content

Improve error reporting: Wrong cast operator (:?> instead of :>) #1127

@isaksky

Description

@isaksky

Related to #1103

What

image

Why

This error message is problematic for newcomers, especially ones from C#, because:

  1. IDictionary<obj,obj> is compatible with Dictionary<obj, obj>
  2. C# only has one cast operator, and this works in C#:
public static IDictionary<object, object> TestM() {
    return new Dictionary<object, object>();
}

Possible solution

Before resorting to this error message, check if the left hand side can be statically cast to the type on the right, and if so, use a "consider using the :> operator" error message instead.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions