[nem-bug] [Nemerle 0000795]: Inconsistent tuple type unification
feedback at nemerle.org
feedback at nemerle.org
Tue Nov 28 05:22:47 CET 2006
A NOTE has been added to this issue.
======================================================================
<http://nemerle.org/bugs/view.php?id=795>
======================================================================
Reported By: Evin Robertson
Assigned To:
======================================================================
Project: Nemerle
Issue ID: 795
Category: Compiler (type engine)
Reproducibility: always
Severity: minor
Priority: normal
Status: new
======================================================================
Date Submitted: 11-27-2006 03:44 CET
Last Modified: 11-28-2006 05:22 CET
======================================================================
Summary: Inconsistent tuple type unification
Description:
public class A
{
}
public class B : A
{
}
public class C
{
public F(x : int) : int * B
{
(x, B());
}
public G() : int * A
{
def (y, b) = F(1);
(y, b);
}
public H() : int * A
{
F(1);
}
}
Observed result: G() compiles fine, but H() gives an error:
pairunify.n:22:5:25:6: error: expected (int * A), got (int * B) in
function return type: the types A and B are not compatible [simple unify]
It doesn't seem like taking apart a tuple and putting it back together
again should be required for this to compile. Because tuples are
immutable, (int * B) should be considered a subtype of (int * A).
======================================================================
----------------------------------------------------------------------
nazgul - 11-27-06 08:09
----------------------------------------------------------------------
> It doesn't seem like taking apart a tuple and putting it back together
again should be required for this to compile. Because tuples are
immutable, (int * B) should be considered a subtype of (int * A).
Tuples in Nemerle are invariant. This is a limitation of .NET generics :(
----------------------------------------------------------------------
Evin Robertson - 11-28-06 05:22
----------------------------------------------------------------------
How about adding implicit conversions for the tuple types? The following
seems to work:
[Record]
public struct MyTuple['p0, 'p1]
{
public field0 : 'p0;
public field1 : 'p1;
public static @: ['f0, 'f1, 'g0, 'g1]
(f : MyTuple['f0, 'f1]) : MyTuple['g0, 'g1]
where 'f0 : 'g0 where 'f1 : 'g1
{
MyTuple(f.field0 : 'g0, f.field1 : 'g1)
}
}
public class A
{
}
public class B : A
{
}
public class C
{
public F(x : int) : MyTuple[int, B]
{
MyTuple(x, B());
}
public H() : MyTuple[int, A]
{
F(1);
}
}
Issue History
Date Modified Username Field Change
======================================================================
11-27-06 03:44 Evin Robertson New Issue
11-27-06 08:09 nazgul Note Added: 0001523
11-28-06 05:22 Evin Robertson Note Added: 0001528
======================================================================
More information about the bugs
mailing list