Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0000372OCamlOCaml generalpublic2001-05-30 12:102001-06-05 09:56
Reporteradministrator 
Assigned To 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionno change required 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0000372: Is nil = _ ?
DescriptionIn the following case it warns for the row | hd::tl ->

'nil' doesn't occur in the reference manual. I would say that this is
a bit dangerous, since most programmers would use say that nil is nil,
i.e. a synononym for [].

let rec foo (l:int list) : unit =
  match l with
  | nil -> ()
  | hd::tl -> foo tl

File "nil.ml", line 4, characters 4-10:
Warning: this match case is unused.

/mattias

TagsNo tags attached.
Attached Files

- Relationships

-  Notes
(0002266)
administrator (administrator)
2001-06-05 09:53

> In the following case it warns for the row | hd::tl ->
> 'nil' doesn't occur in the reference manual. I would say that this is
> a bit dangerous, since most programmers would use say that nil is nil,
> i.e. a synononym for [].
>
> let rec foo (l:int list) : unit =
> match l with
> | nil -> ()
> | hd::tl -> foo tl

"nil" is just an identifier like any other. What you wrote is
equivalent to

let rec foo (l:int list) : unit =
  match l with
  | x -> ()
  | hd::tl -> foo tl

or indeed any name instead of "x", so the first line is a "catch-up"
case. With this in mind, the compiler warning should make sense.

- Xavier Leroy

(0002267)
administrator (administrator)
2001-06-05 09:56

User's misunderstanding.

- Issue History
Date Modified Username Field Change
2005-11-18 10:13 administrator New Issue


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker