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

Incorrect warning about unused match cases with first-class modules in patterns #6194

Closed
vicuna opened this issue Sep 26, 2013 · 2 comments
Closed
Assignees
Labels

Comments

@vicuna
Copy link

@vicuna vicuna commented Sep 26, 2013

Original bug ID: 6194
Reporter: @mmottl
Assigned to: @garrigue
Status: closed (set by @xavierleroy on 2015-12-11T18:24:13Z)
Resolution: fixed
Priority: normal
Severity: minor
Version: 4.01.0
Fixed in version: 4.01.1+dev
Category: ~DO NOT USE (was: OCaml general)
Monitored by: @mmottl

Bug description

Lets consider the following code snippet:


module type S = sig val x : bool end

let f = function
| Some (module M : S) when M.x -> ()
| Some _ -> ()
| None -> ()

The compiler will warn that the second match case is unused. This is incorrect, because the first case is guarded. It seems that the warning mistakenly assumes that matching first-class modules in patterns makes them irrefutable even in the presence of guards.

@vicuna
Copy link
Author

@vicuna vicuna commented Sep 26, 2013

Comment author: @lpw25

The following fatal error is probably related:

(* match.ml *)
module type S = sig val x : bool end

let f = function
| Some (module M : S) when M.x -> ()
| None -> ();;

$ ocamlc match.ml

Fatal error: Matching.comp_exit
Fatal error: exception Misc.Fatal_error

@vicuna
Copy link
Author

@vicuna vicuna commented Sep 26, 2013

Comment author: @garrigue

Fixed in 4.01 branch revision 14189, file parmatch.ml.
Apparently already fixed in trunk (but should check).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants