Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0006680OCamltypingpublic2014-11-28 16:332016-12-07 11:37
Reporterpveber 
Assigned Togarrigue 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionfixed 
PlatformOSOS Version
Product Version4.02.1 
Target VersionFixed in Version4.02.2+dev / +rc1 
Summary0006680: Missing parentheses when printing polymorphic variant value in non exhaustivity warning
DescriptionIn the following, the counter-example produced by the exhaustivity check is not printed correctly:

        OCaml version 4.02.1
                                  
# let f = function `a (`b 1) -> true;;
Warning 8: this pattern-matching is not exhaustive.
Here is an example of a value that is not matched:
`a `b 0
val f : [< `a of [< `b of int ] ] -> bool = <fun>


`a `b 0 should be `a (`b 0)
TagsNo tags attached.
Attached Filesdiff file icon fix-variant-parens.diff [^] (506 bytes) 2014-11-28 17:49 [Show Content]

- Relationships

-  Notes
(0012589)
gasche (administrator)
2014-11-28 17:49

The easy way to fix this is to fix the code of the pretty_* functions in typing/parmatch.ml. A simple patch is attached that fixes the reported issue.

The good way to fix this, in my opinion, is to have this code not pretty-print a value extrapolated from a pattern, but to extrapolate this value into a valid AST tree, and then call the Pprintast functions to print expressions and handle the ugly details of pretty-printings. Pprintast is not a bug-free zone, but we could at least centralize our pretty-printing bugs in a single place.
(0012707)
garrigue (manager)
2014-12-08 09:13

Fixed in trunk and 4.02 are revisions 15640 and 15641.

- Issue History
Date Modified Username Field Change
2014-11-28 16:33 pveber New Issue
2014-11-28 17:49 gasche Note Added: 0012589
2014-11-28 17:49 gasche Status new => acknowledged
2014-11-28 17:49 gasche File Added: fix-variant-parens.diff
2014-12-08 09:13 garrigue Note Added: 0012707
2014-12-08 09:13 garrigue Status acknowledged => resolved
2014-12-08 09:13 garrigue Fixed in Version => 4.02.2+dev / +rc1
2014-12-08 09:13 garrigue Resolution open => fixed
2014-12-08 09:13 garrigue Assigned To => garrigue
2016-12-07 11:37 xleroy Status resolved => closed
2017-02-23 16:45 doligez Category OCaml typing => typing


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker