Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0000151OCamlOCaml generalpublic2000-06-30 01:112000-06-30 03:29
Reporteradministrator 
Assigned To 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionfixed 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0000151: Optional class arguments
DescriptionFull_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.

TagsNo tags attached.
Attached Files

- Relationships

-  Notes
(0000410)
administrator (administrator)
2000-06-30 03:28

> 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
(0000411)
administrator (administrator)
2000-06-30 03:29

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

- Issue History
Date Modified Username Field Change
2005-11-18 10:13 administrator New Issue


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker