Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Type checker errors should be reported when syntax errors are present #17787

Closed
@auduchinok

Description

@auduchinok

Consider this case:

do
    let a = b.ToString()
Screenshot 2024-09-25 at 11 37 57

The are two errors:

  • syntax error: missing in part of the let expression
  • unresolved b name

The second error is not reported. This has been like that for long time where we tried to minimize cascading type checker errors, so some of them are hidden when there are errors in preceding phases. However, with the significantly improved parser recovery it should be much better to report these errors now. Having any in expression helps in this case:

do
    let a = b.ToString()
    ()
Screenshot 2024-09-25 at 11 38 03

But we want a better error reporting while editing too 🙂

The same applies to other case where the parser recovery has been introduced, for example tuple expressions. When there are no syntax errors, type checker errors about the unresolved name and a missing overload are reported:

Math.Max(a)
Screenshot 2024-09-25 at 11 41 06

When typing the second argument (and adding a syntax error in the tuple), the resolved names are reported, but the type checker errors are hidden (even though the parser recovery now allows the subsequent analysis):

Math.Max(a, )
Screenshot 2024-09-25 at 11 41 44

When the syntax error is fixed, everything is reported, even a warning about the unused expression result:

Math.Max(a, 1)
Screenshot 2024-09-25 at 11 43 20

Typing subsequent arguments makes errors blink, which is not great:

Screenshot 2024-09-25 at 11 45 06

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-Diagnosticsmistakes and possible improvements to diagnosticsBugImpact-Low(Internal MS Team use only) Describes an issue with limited impact on existing code.

    Type

    Projects

    Status

    Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions