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

Old bug fixed? #2694

Closed
vicuna opened this issue Feb 27, 2001 · 2 comments
Closed

Old bug fixed? #2694

vicuna opened this issue Feb 27, 2001 · 2 comments
Labels

Comments

@vicuna
Copy link

vicuna commented Feb 27, 2001

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

Bug description

Hi,
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

@vicuna
Copy link
Author

vicuna commented Mar 5, 2001

Comment author: administrator

Consequence of

  • Improved implicit subtypes built by (... :> ty), closer to intuition.

@vicuna vicuna closed this as completed Mar 5, 2001
@vicuna
Copy link
Author

vicuna commented Mar 5, 2001

Comment author: administrator

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

@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