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

Bad interaction between exceptions and classes #4776

Closed
vicuna opened this issue Apr 27, 2009 · 2 comments
Closed

Bad interaction between exceptions and classes #4776

vicuna opened this issue Apr 27, 2009 · 2 comments
Labels

Comments

@vicuna
Copy link

vicuna commented Apr 27, 2009

Original bug ID: 4776
Reporter: @alainfrisch
Status: closed (set by @garrigue on 2009-04-28T05:26:46Z)
Resolution: fixed
Priority: normal
Severity: major
Fixed in version: 3.11.1+dev
Category: ~DO NOT USE (was: OCaml general)
Monitored by: @yakobowski

Bug description

The code generator for classes behaves badly w.r.t. exceptions, as demonstrated by the code below:

============================================================================
module F(X : sig end) = struct
exception A
let a = A

let () =
let o = object method test = match a with A -> print_endline "OK" | _ -> assert false end in
o # test
end

module X = F(struct end)
module Y = F(struct end) (* fails!!! *)

The reason, I believe, is that Env.diff does not take exception constructors into account. As a consequence, the new_ids variable in Translclass.transl_class does not include such constructors and the classes are not closed over them, as they should (as far as I understand compilation of classes).

@vicuna
Copy link
Author

vicuna commented Apr 27, 2009

Comment author: @alainfrisch

I confirm that if one extends Env.t with a new field that keep tracks of all exceptions (one only needs to change the store_exception function and the empty value) and if we use this in Env.diff, the bug is fixed.

@vicuna
Copy link
Author

vicuna commented Apr 28, 2009

Comment author: @garrigue

Fixed by tracking (local) exceptions in Env.diff.

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