You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
Warning 8: this pattern-matching is not exhaustive.
Here is an example of a value that is not matched:
{player1=Spock}
The beginner asks:
AFAIK, I can not create a record with only the first item:
utop[17]> let x = {player1=Spock};;
Error: Some record fields are undefined: player2
I think the beginner is right: this error message is confusing.
I would propose to rephrase it as follows:
Here is an example of a case that is not matched:
{player1=Spock}
(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:
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.
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.
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: