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

Unbound constructor Pervasives.None ... #2553

Closed
vicuna opened this issue May 5, 2004 · 4 comments
Closed

Unbound constructor Pervasives.None ... #2553

vicuna opened this issue May 5, 2004 · 4 comments
Labels

Comments

@vicuna
Copy link

vicuna commented May 5, 2004

Original bug ID: 2553
Reporter: administrator
Status: closed
Resolution: not a bug
Priority: normal
Severity: minor
Category: ~DO NOT USE (was: OCaml general)

Bug description

Full_Name: Pierre HABOUZIT
Version: 3.07
OS: linux
Submission from: amaretto.inria.fr (128.93.8.127)

if you define a type as :

type foo = BarInt of int | BarChar of char | None

in a module "mod", then, if you are using options in another module that make an
«open Mod» it's not possible to access the option 'None' constructor :

open Mod

let my_bug () =
let a = ref None in
...
a := Some 0;
...

will not compile, and fail with :
-> This expression has type Mod.foo but is here used with type 'a option

this is ok. but if you correct the previous thing, with :

let my_bug () =
let a = ref Pervasives.None in ...

you get an :

-> Unbound constructor Pervasives.None

@vicuna
Copy link
Author

vicuna commented May 6, 2004

Comment author: administrator

Full_Name: Pierre HABOUZIT
Version: 3.07
OS: linux
Submission from: amaretto.inria.fr (128.93.8.127)

if you define a type as :

type foo = BarInt of int | BarChar of char | None

in a module "mod", then, if you are using options in another module that make an
«open Mod» it's not possible to access the option 'None' constructor :

open Mod

let my_bug () =
let a = ref None in
...
a := Some 0;
...

will not compile, and fail with :
-> This expression has type Mod.foo but is here used with type 'a option

this is ok. but if you correct the previous thing, with :

let my_bug () =
let a = ref Pervasives.None in ...

you get an :

-> Unbound constructor Pervasives.None

As you can check in the documentation the option type is not defined
in Pervasives.

So this is rather a (mis)feature than a bug.

--
Luc Maranget

@vicuna
Copy link
Author

vicuna commented May 6, 2004

Comment author: administrator

Feature
--Luc 05-06-2004

@vicuna vicuna closed this as completed May 6, 2004
@vicuna
Copy link
Author

vicuna commented May 6, 2004

Comment author: administrator

On Thu, May 06, 2004 at 03:07:16PM +0200, Luc Maranget wrote:

Full_Name: Pierre HABOUZIT
Version: 3.07
OS: linux
Submission from: amaretto.inria.fr (128.93.8.127)

if you define a type as :

type foo = BarInt of int | BarChar of char | None

in a module "mod", then, if you are using options in another module that make an
«open Mod» it's not possible to access the option 'None' constructor :

open Mod

let my_bug () =
let a = ref None in
...
a := Some 0;
...

will not compile, and fail with :
-> This expression has type Mod.foo but is here used with type 'a option

this is ok. but if you correct the previous thing, with :

let my_bug () =
let a = ref Pervasives.None in ...

you get an :

-> Unbound constructor Pervasives.None

As you can check in the documentation the option type is not defined
in Pervasives.

So this is rather a (mis)feature than a bug.
that's indeed true.
but it's painful not to be allowed to have any access to None in this
case ...

I know it's not in Pervasives, but the problem is, it's nowhere with a
module name, and there is nothing like the "::" namespace of C++ ... so
I'm not able to tell, the None i'm aiming to use is the 'a option one.

I know a solution would be :

-----my.ml-----

let none = None

open Mod

let my_correctedbug () =
let a = ref none in
...
a := Some 0;
...

----/my.ml-----

but it's ugly and not very convenient

-PH


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFAmkJGvGr7W6HudhwRAhODAKCGXApe4kZChMnQM09MHAnYLbqFywCcCEO+
iXQWuRnJgzdCEdtaiGwcHmg=
=vy+p
-----END PGP SIGNATURE-----



@vicuna
Copy link
Author

vicuna commented May 14, 2004

Comment author: administrator

As you can check in the documentation the option type is not defined
in Pervasives.

So this is rather a (mis)feature than a bug.

that's indeed true. but it's painful not to be allowed to have any access
to None in this case ...

[...]

I know a solution [...] but it's ugly and not very convenient

I agree that it's ugly. The problem is known---there are a few other
(value, type, ...) identifiers that are really primitive and not bound in
Pervasive.

This could be fixed of course, but the fix for all cases is not just
as «trivial» as one could think.

I still hope that this will be fixed one day...

Didier

@vicuna vicuna added the bug label Mar 19, 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