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

Exception aliasing does not preserve abstraction #5186

Closed
vicuna opened this issue Dec 1, 2010 · 2 comments
Closed

Exception aliasing does not preserve abstraction #5186

vicuna opened this issue Dec 1, 2010 · 2 comments
Labels
Milestone

Comments

@vicuna
Copy link

vicuna commented Dec 1, 2010

Original bug ID: 5186
Reporter: Julien Signoles
Status: closed (set by @xavierleroy on 2015-12-11T18:21:04Z)
Resolution: not a bug
Priority: normal
Severity: minor
Version: 3.11.2
Target version: 4.01.0+dev
Category: ~DO NOT USE (was: OCaml general)
Monitored by: @glondu till @hcarty @Chris00 @yakobowski

Bug description

Hello,

Consider the following program:

exception A
let f () = raise A
module M : sig exception B end = struct exception B = A end

let () =
try f ()
with
| M.B -> Format.printf "M.B@."
| A -> Format.printf "A@."

The output is "M.B" since M.B matches before A. That is consistent with the dynamic semantics of exception aliasing and pattern matching (as far as I understand it) BUT it does not preserve abstraction since the interface of M does not say that M.B is an alias for A. Thus an external user of M cannot expect this behavior.

Sadly, I see no way to circumvent this issue (except to add a textual documentation to the interface of M) :-(.

@vicuna
Copy link
Author

vicuna commented Sep 19, 2012

Comment author: @damiendoligez

I'm not sure this should be considered a bug. Note that the interface of M does not say that M.B is NOT an alias for A, so maybe you shouldn't be surprised when it is.

@vicuna
Copy link
Author

vicuna commented Jul 19, 2013

Comment author: @xavierleroy

"exception A" in a signature doesn't imply that "A" is fresh, just that it is an exception constructor. I agree this can be counter-intuitive, but I don't see anything that can be done about it.

@vicuna vicuna closed this as completed Dec 11, 2015
@vicuna vicuna added this to the 4.01.0 milestone Mar 14, 2019
@vicuna vicuna added the bug label Mar 20, 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