Wording of non-exhaustivity warning is confusing for beginners #7169
Comments
Comment author: @Armael I think it would be quite beneficial to print partial record patterns with a "; _". The fact that the pattern looks like a valid OCaml value was in my eyes the major cause of confusion. |
Comment author: @Octachron I also think that printing a trailing " _ " when the record pattern is not complete is a good idea. Moreover, it seems quite easy to implement this by reusing the warning on non-closed records. I have proposed a PR to this effect in #501. |
Comment author: @gasche Solved by merging octachron's PR. Thanks a lot! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Original bug ID: 7169
Reporter: @gasche
Assigned to: @gasche
Status: resolved (set by @gasche on 2016-07-01T15:17:26Z)
Resolution: fixed
Priority: normal
Severity: text
Version: 4.02.3
Target version: 4.03.1+dev
Fixed in version: 4.04.0 +dev / +beta1 / +beta2
Category: ~DO NOT USE (was: OCaml general)
Related to: #7504
Monitored by: @hcarty
Bug description
In discussion https://www.reddit.com/r/ocaml/comments/49g5yi/doubt_about_pattern_matching/ , a beginner has a two-field records {player1; player2} that he pattern-matches on, and he gets the following non-exhaustivity warning (one possible player value is not handled);
The beginner asks:
I think the beginner is right: this error message is confusing.
I would propose to rephrase it as follows:
(It would also possibly be a good idea to print partial record patterns with a trailing "; _" in this case, to highlight that this is not expected to be a constructible value, but I'm not sure whether that part is worth the trouble.)
The text was updated successfully, but these errors were encountered: