Fsharp: Highly confusing error with single whitespace change in a list expression

Created on 7 Aug 2018  Â·  5Comments  Â·  Source: dotnet/fsharp

  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

Area-Compiler Feature Improvement error recovery

Most helpful comment

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
.

All 5 comments

Wow, this is bad.

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.

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.

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
.

@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.

Was this page helpful?
0 / 5 - 0 ratings