* [Caml-list] Warning 28.
@ 2013-06-05 5:26 Ivan Gotovchits
2013-06-05 6:54 ` Virgile Prevosto
0 siblings, 1 reply; 4+ messages in thread
From: Ivan Gotovchits @ 2013-06-05 5:26 UTC (permalink / raw)
To: caml-list
After switching to a newer version of Ocaml I've started to receive
some interesting warnings on my old codebase. And there is one warning
that I do not understand. I have the following patter matching:
...
| Ref n -> ...
...
where Ref is:
type t =
...
| Ref of int
Compiler issues me a warning:
«Warning 28: wildcard pattern given as argument to a constant constructor»
Sorry, but if I understand this wording correctly, then I do not see
anything criminal in issuing a wildcard pattern to a constant
constructor. What is wrong?
--
(__)
(oo)
/------\/
/ | ||
* /\---/\
~~ ~~
...."Have you mooed today?"...
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Caml-list] Warning 28.
2013-06-05 5:26 [Caml-list] Warning 28 Ivan Gotovchits
@ 2013-06-05 6:54 ` Virgile Prevosto
2013-06-05 7:04 ` Ivan Gotovchits
0 siblings, 1 reply; 4+ messages in thread
From: Virgile Prevosto @ 2013-06-05 6:54 UTC (permalink / raw)
Cc: OCAML
Hello Ivan,
2013/6/5 Ivan Gotovchits <ivg@ieee.org>:
> | Ref n -> ...
> ...
>
> where Ref is:
>
> type t =
> ...
> | Ref of int
>
> Compiler issues me a warning:
>
> «Warning 28: wildcard pattern given as argument to a constant constructor»
>
> Sorry, but if I understand this wording correctly, then I do not see
> anything criminal in issuing a wildcard pattern to a constant
> constructor. What is wrong?
OCaml is not complaining about your Ref constructor, but another one
that does not have any argument, but is nevertheless given a wildcard
pattern in the matching, as e.g. None in
the following code:
# let f default = function
| Some n -> n
| None _ -> default;;
Warning 28: wildcard pattern given as argument to a constant constructor
The 'None _' is suspicious at best. Tolerating such kind of pattern
reportedly eases generation of OCaml code, and that's why it is a
warning and not a plain error.
Best regards,
--
E tutto per oggi, a la prossima volta
Virgile
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Caml-list] Warning 28.
2013-06-05 6:54 ` Virgile Prevosto
@ 2013-06-05 7:04 ` Ivan Gotovchits
2013-06-05 7:22 ` Alain Frisch
0 siblings, 1 reply; 4+ messages in thread
From: Ivan Gotovchits @ 2013-06-05 7:04 UTC (permalink / raw)
To: Virgile Prevosto; +Cc: OCAML
Virgile Prevosto <virgile.prevosto@m4x.org> writes:
> OCaml is not complaining about your Ref constructor, but another one
> that does not have any argument, but is nevertheless given a wildcard
> pattern in the matching, as e.g. None in
> the following code:
>
> # let f default = function
> | Some n -> n
> | None _ -> default;;
> Warning 28: wildcard pattern given as argument to a constant constructor
>
Indeed, right above there was a true constant constructor with a
wildcard, though, for some reason, compiler was wrong in his estimation
of the error position, that confused me.
Thanks!
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Caml-list] Warning 28.
2013-06-05 7:04 ` Ivan Gotovchits
@ 2013-06-05 7:22 ` Alain Frisch
0 siblings, 0 replies; 4+ messages in thread
From: Alain Frisch @ 2013-06-05 7:22 UTC (permalink / raw)
To: Ivan Gotovchits, Virgile Prevosto; +Cc: OCAML
On 06/05/2013 09:04 AM, Ivan Gotovchits wrote:
> for some reason, compiler was wrong in his estimation
> of the error position, that confused me.
Could you produce a simple reproduction case and submit it to the
bugtracker?
-- Alain
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-06-05 7:22 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-06-05 5:26 [Caml-list] Warning 28 Ivan Gotovchits
2013-06-05 6:54 ` Virgile Prevosto
2013-06-05 7:04 ` Ivan Gotovchits
2013-06-05 7:22 ` Alain Frisch
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox