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

Uncaught Not_found exception with a hidden .cmi file #6384

Closed
vicuna opened this issue Apr 29, 2014 · 1 comment
Closed

Uncaught Not_found exception with a hidden .cmi file #6384

vicuna opened this issue Apr 29, 2014 · 1 comment
Assignees

Comments

@vicuna
Copy link

vicuna commented Apr 29, 2014

Original bug ID: 6384
Reporter: @lpw25
Assigned to: @garrigue
Status: closed (set by @xavierleroy on 2015-12-11T18:26:43Z)
Resolution: fixed
Priority: normal
Severity: minor
Version: 4.01.0
Fixed in version: 4.02.0+dev
Category: typing

Bug description

By hiding a .cmi file you can get an uncaught Not_found exception:

$ cat a.mli
type t = Foo | Bar

$ cat b.mli
type t = A.t

$ cat c.mli
type t = A.t = Foo | Bar

$ cat d.ml
let f (x : B.t) =
  match x with
    C.Foo -> true
  | _ -> false

$ ocamlc a.mli b.mli c.mli

$ rm a.cmi

$ ocamlc d.ml
Fatal error: exception Not_found

The attached patch fixes this bug. The important change is that "complete_constrs" in parmatch.ml uses the type from the constructor instead of from the pattern.

It also cleans up some other code in parmatch.ml to remove some unnecessary checks that a type has a variant/record definition (since that should makes bugs like this less likely).

File attachments

@vicuna
Copy link
Author

vicuna commented Apr 29, 2014

Comment author: @garrigue

Applied the patch to trunk at revision 14702.

Indeed, there was a lot of garbage now that constructors contain their names.
Thanks for cleaning up that.

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

No branches or pull requests

2 participants