jayduhon / inferno-os

Automatically exported from code.google.com/p/inferno-os
2 stars 0 forks source link

Cyclic references with polymorphic types fails with member functions #47

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
The following code fails with an error
'foo.b:xx: spurious cyclic qualifier for field link of adt Node[T]'

Node: adt[T] {
    new: fn(): ref Node[T];
    x: T;
    link: cyclic ref Node[T];
};

Node[T].new(): ref Node[T]
{
    return ref Node[T] (nil,nil);
}

However the following compiles without a problem:

Node: adt {
    new: fn(): ref Node;
    x: int;
    link: cyclic ref Node;
};

Node.new(): ref Node
{
    return ref Node (0, nil);
}

The only difference is that the former construct uses polymorphic types
whereas the latter does not.

Original issue reported on code.google.com by ja...@basen.net on 24 Apr 2007 at 9:09

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by Charles....@gmail.com on 12 Jun 2008 at 10:28

GoogleCodeExporter commented 9 years ago
There are two workarounds to this problem:
* if there is one more cyclic ref Node added to the Node (see bug-2.b)
* or if the Node[T].new method is removed (see bug-3.b)

Hope this helps to further investigate and finally fix the problem.

Original comment by ostap.ch...@gmail.com on 6 Apr 2009 at 6:22

Attachments: