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
Warning 27 shouldn't trigger on optional argument names #7282
Comments
Comment author: @dra27 3.09.0 is where it was introduced, not the version I'm using! |
Comment author: @alainfrisch What's wrong with:
? |
Comment author: @dra27 Nothing! But where's it documented??? It should be probably be mentioned in Chapter 4? I didn't even know that syntax was available! Could the text of Warning 27 be customised in this particular instance? It's not really a variable? |
Comment author: @gasche It is documented in a way that could be clarified:
We should explicitate that any pattern can be used, and in particular that _ (or a variable name of the form _bar) can be used to ignore the variable. I'm afraid it may be difficult, from an implementation point of view, to specialize the warning text -- but I would support doing so. TODO: add information to the manual. |
Comment author: @alainfrisch The actual "reference" documentation is: http://caml.inria.fr/pub/docs/manual-ocaml/expr.html#parameter and:
|
Comment author: @gasche Indeed; dra mentioned Chapter 4, which is the tutorial part of label and variants, and it is the one that could become more informative. The reference part is fine, but in its usual cold-hearted way. |
Original bug ID: 7282
Reporter: @dra27
Assigned to: @gasche
Status: closed (set by @xavierleroy on 2017-09-24T15:33:03Z)
Resolution: not a bug
Priority: normal
Severity: tweak
Version: 3.09.0
Category: ~DO NOT USE (was: OCaml general)
Bug description
Warning 27 triggers on an optional argument if the variable isn't used in the code. The warning either shouldn't trigger, or should have a separate number.
Steps to reproduce
let foo ?bar () = ()
in
f ()
$ ocamlc -w +27 foo.ml
File "foo.ml", line 1, characters 9-12:
Warning 27: unused variable bar.
Additional information
This is a nuisance when writing functions designed to match a module type. In all (?) other cases, there is a syntax for working around this (e.g. prefixing with _ or just using the wildcard character)
The text was updated successfully, but these errors were encountered: