Version française
Home     About     Download     Resources     Contact us    
Browse thread
Bugs with pattern-matching and exceptions
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Louis Gesbert <louis.gesbert@l...>
Subject: Re: [Caml-list] Bugs with pattern-matching and exceptions
> Can you reproduce this failure of the type system in the top-level
> without using marshalling? I haven't been able to.

Yes, this was without marshalling: when you use an alias to an exception
which has been redefined afterwards, some type information seems to be lost
by the top-level.

# type t = X;;
type t = X
# exception E of t;;
exception E of t
# exception E' = E;;
exception E' of t
# E' X;;
- : exn = E X
# exception E of string;;
exception E of string
# E' X;;
- : exn = E 0

Here we alias E with E', then redefine E (no matter with what), and E'
shows its argument as int... However, this seems to be only a problem with
the toplevel pretty-printer, not a real type problem since I didn't manage
to make O'Caml accept badly typed expressions this way. This is with O'Caml
3.09.1.

I guess this is linked to the problems of equality and marshalling:
exceptions are non-standard variant types which confuse the run-time in
some dark corners.