Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing parentheses when printing polymorphic variant value in non exhaustivity warning #6680

Closed
vicuna opened this Issue Nov 28, 2014 · 2 comments

Comments

Projects
None yet
2 participants
@vicuna
Copy link
Collaborator

commented Nov 28, 2014

Original bug ID: 6680
Reporter: pveber
Assigned to: @garrigue
Status: closed (set by @xavierleroy on 2016-12-07T10:37:05Z)
Resolution: fixed
Priority: normal
Severity: minor
Version: 4.02.1
Fixed in version: 4.02.2+dev / +rc1
Category: typing

Bug description

In 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 =

a b 0 should be a (b 0)

File attachments

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

commented Nov 28, 2014

Comment author: @gasche

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.

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

commented Dec 8, 2014

Comment author: @garrigue

Fixed in trunk and 4.02 are revisions 15640 and 15641.

@vicuna vicuna closed this Dec 7, 2016

@vicuna vicuna added the typing label Mar 14, 2019

@vicuna vicuna added the bug label Mar 20, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.