dotnet / fsharp

The F# compiler, F# core library, F# language service, and F# tooling integration for Visual Studio
https://dotnet.microsoft.com/languages/fsharp
MIT License
3.88k stars 783 forks source link

Highly confusing error with single whitespace change in a list expression #5471

Open cartermp opened 6 years ago

cartermp commented 6 years ago
  1. Open StructureTests.fs
  2. Modify an existing test to offset some whitespace in the list expression
[<Test>]
let ``match``() =
    """
match None with     // 2
| Some _ ->         // 3
    ()              // 4
| None ->           // 5
    match None with // 6
    | Some _ -> ()  // 7
    | None ->       // 8
        let x = ()  // 9
        ()          // 10
"""
    => [  (1, 0, 11, 0), (1, 0, 11, 0) // Note this is one space over
         (2, 0, 10, 10), (2, 15, 10, 10)
         (6, 4, 10, 10), (5, 6, 10, 10)
         (6, 4, 10, 10), (6, 19, 10, 10)
         (9, 8, 10, 10), (8, 10, 10, 10) ]

Result:

Type mismatch error.

wtf

TIHan commented 6 years ago

Wow, this is bad.

isaacabraham commented 6 years ago

Is this really so unusual? There are loads of weird and wonderful error messages you'll get by indenting something by one character throughout the language.

TIHan commented 6 years ago

It's not unusual in F#, but that doesn't mean we should ignore it.

It's a barrier to entry for newcomers to F#. I had someone tell me they didn't get into F# because the compile errors were not good enough for him; meaning he had trouble learning F# due to the compiler not telling him what is wrong with his code, and how to resolve it.

While we don't need to be perfect, we should identify as many cases as we can to see if we can improve the experience.

forki commented 6 years ago

Yes we can really see how improved error message help newcomers. Even simple things like spelling suggestions help so much.

Will Smith notifications@github.com schrieb am Mi., 8. Aug. 2018, 09:31:

It's not unusual in F#, but that doesn't mean we should ignore it.

It's a barrier to entry for newcomers to F#. I had someone tell me they didn't get into F# because the compile errors were not good enough for him; meaning he had trouble learning F# due to the compiler not telling him what is wrong with his code, and how could resolve it.

While we don't need to be perfect, we should identify as many cases as we can to see if we can improve the experience.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/Microsoft/visualfsharp/issues/5471#issuecomment-411314041, or mute the thread https://github.com/notifications/unsubscribe-auth/AADgNH-Y9djkp5oPTp0n1zrEaBtrvQSXks5uOpPIgaJpZM4Vy6ai .

isaacabraham commented 6 years ago

@TIHan No doubt - you know I've been doing a lot with errors for beginners :-) I'm just used to this particular one because it happens everywhere. And yes, it definitely does confuse newcomers to the language - I see it all the time when doing F# training courses.