[nem-bug] [Nemerle 0000789]: Incorrect type is inferred in lambda
expression when iterated list consists of members that
support multiple interfaces
feedback at nemerle.org
feedback at nemerle.org
Mon Nov 20 15:05:55 CET 2006
The following issue has been RESOLVED.
======================================================================
<http://nemerle.org/bugs/view.php?id=789>
======================================================================
Reported By: akhropov
Assigned To: malekith
======================================================================
Project: Nemerle
Issue ID: 789
Category: Compiler (type engine)
Reproducibility: always
Severity: minor
Priority: normal
Status: resolved
Resolution: fixed
Fixed in Version:
======================================================================
Date Submitted: 11-16-2006 14:58 CET
Last Modified: 11-20-2006 15:05 CET
======================================================================
Summary: Incorrect type is inferred in lambda expression when
iterated list consists of members that support multiple interfaces
Description:
The following code:
--------------------------------------------------
interface I1{ f1(x:int):int; }
interface I2{ f2(x:int):int; }
class M1 : I1, I2
{
public f1(x:int):int {x+1}
public f2(x:int):int {x+2}
}
class M2 : I1, I2
{
public f1(x:int):int {x-1}
public f2(x:int):int {x-2}
}
def x1 = 5;
def Processors = [M1() : I2,M2() : I2];
def y = Processors.Map( m =>
match(m) {
| m is M1 => m.f1(x1)
| m is M2 => m.f2(x1)
| _ => x1
} );
System.Console.WriteLine($"y = $y");
--------------------------------------------------
results in the following compiler complaints:
--------------------------------------------------
D:\MyProjects\Nemerle>ncc Interfaces.n
Interfaces.n:31:7:31:14:
&http://nemerle.org/bugs/view.php?id=8592;[01;31merror&http://nemerle.org/bugs/view.php?id=8592;[0m:
matched value has
type M1 while the
pattern enforces M2
Interfaces.n:32:7:32:8:
&http://nemerle.org/bugs/view.php?id=8592;[01;33mwarning&http://nemerle.org/bugs/view.php?id=8592;[0m:
this match clause
is unused
Interfaces.n:28:9:28:26:
&http://nemerle.org/bugs/view.php?id=8592;[01;31merror&http://nemerle.org/bugs/view.php?id=8592;[0m:
in argument http://nemerle.org/bugs/view.php?id=1 (f)
of Processors.Map
.[?], needed a I2- -> ?, got M1 -> int-: I2 is not a subtype of M1 [simple
requi
re]
--------------------------------------------------
======================================================================
----------------------------------------------------------------------
malekith - 11-20-06 15:05
----------------------------------------------------------------------
Resolved on trunk r6968.
Issue History
Date Modified Username Field Change
======================================================================
11-16-06 14:58 akhropov New Issue
11-20-06 15:05 malekith Status new => resolved
11-20-06 15:05 malekith Resolution open => fixed
11-20-06 15:05 malekith Assigned To => malekith
11-20-06 15:05 malekith Note Added: 0001514
======================================================================
More information about the bugs
mailing list