Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0000297OCamlOCaml generalpublic2001-02-27 19:072001-03-05 02:59
Reporteradministrator 
Assigned To 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionno change required 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0000297: Old bug fixed?
DescriptionHi,
    The following code compiled fine under 3.0 but doesn't compile under
3.00 + 22. I'm not complaining, since there was a type problem which is now
flagged, but since I don't think this was in the "Changes" file I thought
someone might be interested. Uncommenting the commented part of hier_base
fixes the problem. I was a bit lazy to minimize the error so I hope this is
small enough ;-).

-- Brian

(* **********************************************************************
*)

type orientation =
    R0
  | R90
  | R180
  | R270
  | MX
  | MY (* mirrored about the y axis *)
  | MXR90 (* mirrored about the x axis and then rotated *)
  | MYR90

type ipoint = int * int
let zero = 0

type placement =
  { origin : ipoint
  ; orientation : orientation
  }

type term_kind =
    Power
  | Ground

type term_side = North | South | East | West | Internal

type term =
  { term_name : string
  ; term_kind : term_kind
  ; term_side : term_side
  ; term_point : ipoint
  ; term_layer : string
  ; term_width : int
  ; term_depth : int
  ; term_equiv : string
  }

type ('a, 'b) node = Leaf_node of 'a | Hier_node of 'b

type ('a,'b) instance =
    CellRef of (string * ('a, 'b) node * placement)
  | CellArrayRef of (string * ('a, 'b) node * placement * ipoint * ipoint * ipoint)

class virtual leaf_intf =
  object
    (* The Composite interface *)
    method virtual full_view : (leaf_intf, hier_intf) node
    (* The Visitor interface *)
    method virtual accept : visitor_intf -> placement -> unit

    (* The leaf cell interface *)
    method virtual name : string
    method virtual iname : string
    method virtual kind : string
    method virtual extents : int * int (* (x_size, y_size) *)
    method virtual terms : term list
    method virtual outline : (int * int) array
    method virtual generate : unit
  end
and virtual hier_intf =
  object
    inherit leaf_intf
    method virtual leaf_view : (leaf_intf, hier_intf) node
    method virtual insts : (leaf_intf, hier_intf) instance list
  end
and virtual visitor_intf =
  object
    method virtual visit : (leaf_intf, hier_intf) node -> placement -> unit
    method virtual visit_leaf : leaf_intf -> placement -> unit
    method virtual visit_hier : hier_intf -> placement -> unit
  end

type inst = (leaf_intf, hier_intf) instance
and inst_list = inst list

(* Some root classes *)
class virtual leaf_base kind name iname extents terms outline =
  object (self)
    inherit leaf_intf
    method kind = kind
    method name = name
    method iname = iname
    method extents = extents
    method terms = terms
    method outline = outline
    method full_view = Leaf_node (self :> leaf_intf)
    method accept visitor placement =
      visitor#visit_leaf (self :> leaf_intf) placement
  end

class virtual hier_base insts kind name iname extents terms outline =
  object (self)
    (* inherit hier_intf *) (* In 3.00, omitting this is not a bug *)
    inherit leaf_base kind name iname extents terms outline

    method insts = insts

    method full_view = Hier_node (self :> hier_intf)
    method leaf_view = Leaf_node (self :> leaf_intf)
    method accept visitor placement =
      visitor#visit_hier (self :> hier_intf) placement
  end

TagsNo tags attached.
Attached Files

- Relationships

-  Notes
(0002228)
administrator (administrator)
2001-03-05 02:59

Consequence of
- Improved implicit subtypes built by (... :> ty), closer to intuition.
(0002229)
administrator (administrator)
2001-03-05 10:58

> The following code compiled fine under 3.0 but doesn't compile under
> 3.00 + 22. I'm not complaining, since there was a type problem which is now
> flagged, but since I don't think this was in the "Changes" file I thought
> someone might be interested. Uncommenting the commented part of hier_base
> fixes the problem. I was a bit lazy to minimize the error so I hope this is
> small enough ;-).

It seems related to this line in Changes:
Type-checking:
- Improved implicit subtypes built by (... :> ty), closer to intuition.

What happens is that simple coercions were improved to give better
(not exactly more) polymorphism, which is good in general, but may
mean that something that was monomorphic before becomes polymorphic,
which is illegal in a class definition.

Another way to make typing correct is to specify more your coercion:
method full_view = Hier_node (self : #hier_intf :> hier_intf)

Jacques


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


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker