Skip to content

improve function type error messages by showing what's incompatible #25170

Closed
@jmesserly

Description

@jmesserly

Function type error messages from strong-mode can be hard to understand. It took me a while to decipher this:

Invalid override. The type of FunctionTypeImpl.substitute2 ((List<DartType>, List<DartType>, [List<FunctionTypeAliasElement>]) → DartType) is not a subtype of FunctionType.substitute2 ((List<DartType>, List<DartType>) → FunctionType).lib/src/generated/element.dart, line 5713

I think the issue is the horizontal scrolling ... the thing that's wrong is pushed way off the right side, in both Atom and IntelliJ it's very hard to see the return type is different.

@vsmenon had an idea: we can instead say something about the return type:

Return type DartType is not a subtype of FunctionType, in the override FunctionTypeImpl.substitute2 (overridden from FunctionType.substitute2).

I'd be good to check other tools (for Dart but also other languages) to get some ideas on what works best here.

Of course, they won't always be that easy, but a few special cases can probably handle a lot of the common errors.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2A bug or feature request we're likely to work onclosed-duplicateClosed in favor of an existing reportlegacy-area-analyzerUse area-devexp instead.type-enhancementA request for a change that isn't a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions