Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0004675OCamlOCaml generalpublic2008-12-17 16:072009-12-08 17:49
ReporterPascal Cuoq 
Assigned To 
PlatformOSOS Version
Product Version3.11.0+beta 
Target VersionFixed in Version3.12.0+dev 
Summary0004675: Compiler fails to warn about pattern Top _ when Top is a 0-ary constructor
Description# type t = Top | Base of int ;;
type t = Top | Base of int
# let f x = match x with Base _ -> 0 | Top _ -> 1 ;;

R├ęsultat obtenu :
val f : t -> int = <fun>

R├ęsultat attendu :
Error: The constructor Top expects 0 argument(s),
       but is here applied to 1 argument(s)

TagsNo tags attached.
Attached Files

- Relationships
related to 0004052closed Constructeur constant et _ 
has duplicate 0004717closed Ocaml does not warn about invalid wildcard uses 
has duplicate 0004835closed None _ accepted as pattern match 
has duplicate 0004911closed weird behaviour of underscore in pattern matching 

-  Notes
doligez (administrator)
2008-12-17 18:52

This is a feature that was implemented to facilitate automatic generation of OCaml code...
Pascal Cuoq (reporter)
2008-12-18 00:53

I can see how some camlp4 extensions may get lighter this way,
but the principle behind any single OCaml warning is that
it's better to alert the programmer at the first sign that she
might be confused about her program (the earlier the better),
and this feature is certainly not homogeneous with
this (desirable) general principle.

Shouldn't the pattern generated by camlp4 be something that
does not coincide with something that a human programmer might
write by accident and want to hear about? "Top _" is already as
ugly as it gets, therefore if a camlp4 extension is generating this
it does not look like a very big stretch to force it
to generate "Top __" or "Top ((_))" or whatever other construct that
1) would also work if the constructor had arguments, so as not to
return to the initial problem, and
2) no-one in her right mind would write.
Etienne Millon (reporter)
2009-07-15 15:51

I agree with Pascal Cuoq. It may be nice to factor some camlp4 code, but it creates a nasty compatibility issue.
doligez (administrator)
2009-11-06 19:15
edited on: 2009-11-09 15:13

In 3.12.0, there will be a warning (off by default) for when you give
an _ as argument to a constant constructor.

- Issue History
Date Modified Username Field Change
2008-12-17 16:07 Pascal Cuoq New Issue
2008-12-17 18:51 doligez Relationship added related to 0004052
2008-12-17 18:52 doligez Note Added: 0004804
2008-12-17 18:52 doligez Status new => feedback
2008-12-18 00:53 Pascal Cuoq Note Added: 0004805
2009-02-16 10:05 ertai Relationship added has duplicate 0004717
2009-07-15 15:06 xclerc Relationship added has duplicate 0004835
2009-07-15 15:51 Etienne Millon Note Added: 0005023
2009-11-06 19:02 doligez Relationship added has duplicate 0004911
2009-11-06 19:15 doligez Note Added: 0005150
2009-11-09 15:13 doligez Note Edited: 0005150
2009-11-09 15:13 doligez Note Edited: 0005150
2009-12-08 17:49 doligez Status feedback => closed
2009-12-08 17:49 doligez Resolution open => fixed
2009-12-08 17:49 doligez Fixed in Version => 3.12.0+dev

Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker