Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0005502OCamlOCaml generalpublic2012-02-09 00:232013-08-31 12:46
Reporterjohn_nowak 
Assigned Togasche 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionno change required 
PlatformOSOS Version
Product Version3.12.1 
Target VersionFixed in Version 
Summary0005502: Pattern matching allows wildcards to be used with nullary constructors
DescriptionThe following should most likely be rejected but are accepted by the compiler:

  fun (None _) -> 42
  match None with None _ -> 42
  ...

This bug appears to only be present with wildcards; all other pattern arguments to nullary constructors result in the appropriate error.
TagsNo tags attached.
Attached Files

- Relationships

-  Notes
(0006902)
john_nowak (reporter)
2012-02-09 00:25

I should note that this is actually a minor portability issue. Older OCaml compilers (e.g. 3.10.2) will reject such code.
(0006903)
gasche (developer)
2012-02-09 07:34
edited on: 2012-02-09 07:37

This is not a bug but a dubious feature. This behavior is intentional: `Foo _` will ignore the constructor at any arity (including zero). This is so you don't have to write eg. `Foo (_, _, _, _)` if the arity is four, which would be rather painful.

PS: but you can ask to be warned in the case where this construct is used on a constant constructor (arity zero): it's warning 28, introduced in 3.12.0.


- Issue History
Date Modified Username Field Change
2012-02-09 00:23 john_nowak New Issue
2012-02-09 00:25 john_nowak Note Added: 0006902
2012-02-09 07:34 gasche Note Added: 0006903
2012-02-09 07:37 gasche Note Edited: 0006903 View Revisions
2012-02-09 07:37 gasche Status new => resolved
2012-02-09 07:37 gasche Resolution open => no change required
2012-02-09 07:37 gasche Assigned To => gasche
2013-08-31 12:46 xleroy Status resolved => closed


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker