[nem-bug] [Nemerle 0000805]: Does not report inability to infer
type arguments
feedback at nemerle.org
feedback at nemerle.org
Fri Dec 8 23:41:27 CET 2006
A NOTE has been added to this issue.
======================================================================
<http://nemerle.org/bugs/view.php?id=805>
======================================================================
Reported By: Evin Robertson
Assigned To:
======================================================================
Project: Nemerle
Issue ID: 805
Category: Compiler (type engine)
Reproducibility: always
Severity: minor
Priority: normal
Status: new
======================================================================
Date Submitted: 12-08-2006 23:04 CET
Last Modified: 12-08-2006 23:41 CET
======================================================================
Summary: Does not report inability to infer type arguments
Description:
The following code prints "false" because nemerle is unable to infer the
type parameter to F, making the call A.F.[object](y). gmcs rejects the
equivalent C# program. I think nemerle should do the same. Attached is a
patch to implement an error, which may or may not be in the right place.
public class X
{
}
public class Y['t] : X
{
}
public module A
{
public F['t](x : X) : bool
{
x is Y['t];
}
public Main() : void
{
def y = Y() : Y[int];
def isY = A.F(y).ToString();
System.Console.WriteLine(isY);
}
}
======================================================================
----------------------------------------------------------------------
nazgul - 12-08-06 23:41
----------------------------------------------------------------------
Oh, this is quite controversial request. I usually like this feature,
because it allows me to use any generic objects and methods without really
caring if types were inferred to something specific.
For example I do:
def x = Hashtable ();
x.Add ("aaa", null);
x.Add ("bbb", null);
when (x.Contains (ReadLine()))
WriteLine ("Got it");
and the second generic parameter is not important for me.
My rule of thumb is "if parameters were not inferred, then they are not
important - neither input arguments nor return type make any use of
them".
Of course I also see that if you use many type-checks on generic arguments
you would probably like compiler to prevent you having a bit "undefined"
behavior of your code.
Issue History
Date Modified Username Field Change
======================================================================
12-08-06 23:04 Evin Robertson New Issue
12-08-06 23:04 Evin Robertson File Added: CannotInfer.patch
12-08-06 23:41 nazgul Note Added: 0001571
======================================================================
More information about the bugs
mailing list