Skip to content
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

Is nil = _ ? #2771

Closed
vicuna opened this issue May 30, 2001 · 2 comments
Closed

Is nil = _ ? #2771

vicuna opened this issue May 30, 2001 · 2 comments
Labels

Comments

@vicuna
Copy link

vicuna commented May 30, 2001

Original bug ID: 372
Reporter: administrator
Status: closed
Resolution: not a bug
Priority: normal
Severity: minor
Category: ~DO NOT USE (was: OCaml general)

Bug description

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

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

/mattias

@vicuna
Copy link
Author

vicuna commented Jun 5, 2001

Comment author: administrator

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

@vicuna
Copy link
Author

vicuna commented Jun 5, 2001

Comment author: administrator

User's misunderstanding.

@vicuna vicuna closed this as completed Jun 5, 2001
@vicuna vicuna added the bug label Mar 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant