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

Optional class arguments #2511

Closed
vicuna opened this issue Jun 29, 2000 · 2 comments
Closed

Optional class arguments #2511

vicuna opened this issue Jun 29, 2000 · 2 comments
Labels

Comments

@vicuna
Copy link

vicuna commented Jun 29, 2000

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

Bug description

Full_Name: Gerd Stolpmann
Version: 3.00
OS: Linux
Submission from: p3e9c36a8.dip0.t-ipconnect.de (62.156.54.168)

Hi,

this does not work (classical mode):

class x ?(p = 1) () =
object
val v = p

method m =
  new x ~p:2  ()

end

Error: "The expression "new x" has type ?p:int -> unit -> x but is used with
type
int -> unit -> 'a"

new x ~p:2 () from outside the class works (if I comment m out).

If I change the method m to:

method m = new x ?p:(Some 2) ()

it works again, too.

This looks very strange, and I think it is a bug.

@vicuna
Copy link
Author

vicuna commented Jun 30, 2000

Comment author: administrator

Full_Name: Gerd Stolpmann

this does not work (classical mode):

class x ?(p = 1) () =
object method m = new x ~p:2 () end

Error: "The expression "new x" has type ?p:int -> unit -> x but is used with
type
int -> unit -> 'a"

This looks very strange, and I think it is a bug.

This is again due to the the non-principality of the typing of optionals.
That is, in 3.00 the type information for the constructor is not available
inside
the class, only after it has been defined.
I admit this can be disturbing, since for "let rec" definitions special
processing
is done in order to provide such type information.

I added such preprocessing for classes too, and your example now compiles
correctly.

Jacques

@vicuna
Copy link
Author

vicuna commented Jun 30, 2000

Comment author: administrator

Fixed by Jacques on 2000-06-30.
(Added an approximation of the class constructor)

@vicuna vicuna closed this as completed Jun 30, 2000
@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