Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0007169OCaml~DO NOT USE (was: OCaml general)public2016-03-08 17:552017-03-15 00:16
Assigned Togasche 
PlatformOSOS Version
Product Version4.02.3 
Target Version4.03.1+devFixed in Version4.04.0 +dev / +beta1 / +beta2 
Summary0007169: Wording of non-exhaustivity warning is confusing for beginners
DescriptionIn discussion [^] , 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);

> 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.)
TagsNo tags attached.
Attached Files

- Relationships
related to 0007504resolvedoctachron Case suggested by exhaustivity checker is wrong 

-  Notes
Armael (manager)
2016-03-08 18:54

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.
octachron (developer)
2016-03-09 15:48

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 [^]
gasche (administrator)
2016-07-01 17:17

Solved by merging octachron's PR. Thanks a lot!

- Issue History
Date Modified Username Field Change
2016-03-08 17:55 gasche New Issue
2016-03-08 17:55 gasche Status new => acknowledged
2016-03-08 18:54 Armael Note Added: 0015456
2016-03-09 15:48 octachron Note Added: 0015457
2016-07-01 17:17 gasche Note Added: 0016033
2016-07-01 17:17 gasche Status acknowledged => resolved
2016-07-01 17:17 gasche Fixed in Version => 4.04.0 +dev / +beta1 / +beta2
2016-07-01 17:17 gasche Resolution open => fixed
2016-07-01 17:17 gasche Assigned To => gasche
2017-02-23 16:36 doligez Category OCaml general => -OCaml general
2017-03-03 17:55 doligez Category -OCaml general => -(deprecated) general
2017-03-03 18:01 doligez Category -(deprecated) general => ~deprecated (was: OCaml general)
2017-03-06 17:04 doligez Category ~deprecated (was: OCaml general) => ~DO NOT USE (was: OCaml general)
2017-03-15 00:16 gasche Relationship added related to 0007504

Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker