[nem-bug] [Nemerle 0000975]: Incorrect type resolution

feedback at nemerle.org feedback at nemerle.org
Wed Mar 21 17:00:28 CET 2007


A NOTE has been added to this issue.
======================================================================
<http://nemerle.org/bugs/view.php?id=975> 
======================================================================
Reported By:                VladD2
Assigned To:                
======================================================================
Project:                    Nemerle
Issue ID:                   975
Category:                   Compiler
Reproducibility:            always
Severity:                   minor
Priority:                   high
Status:                     new
======================================================================
Date Submitted:             03-19-2007 23:36 CET
Last Modified:              03-21-2007 17:00 CET
======================================================================
Summary:                    Incorrect type resolution
Description: 
using System;
using System.Console;
using Nemerle.Utility;

module Program
{
  Main() : void
  {
    def lst = [1, 2, 3, 52];
    def ary = NCollectionsUtils.MapToArray(lst, Convert.ToString); //E:
typing fails on ambiguity between overloads:
      // Posible overload: method System.Convert.ToString(value :
System.Object) : string
      // Posible overload: method System.Convert.ToString(value : int) :
string
    WriteLine(ary.ToList());
  }
}

The compiler should prefer 'int -> string' vertion of function.
======================================================================

----------------------------------------------------------------------
 malekith - 03-21-07 14:54 
----------------------------------------------------------------------
Possible workaround is to use:

  def ary = NCollectionsUtils.MapToArray(lst, x : int =>
Convert.ToString(x)); 

another is:

  def ary = NCollectionsUtils.MapToArray(lst, Convert.ToString(_)); 

I agree this shouldn't happen though :/

----------------------------------------------------------------------
 VladD2 - 03-21-07 17:00 
----------------------------------------------------------------------
> Possible workaround is to use:
> def ary = NCollectionsUtils.MapToArray(lst, x : int =>
Convert.ToString(x)); 

I use this code in macro. It's hard to calculate type of parametr :(.

> another is:
> def ary = NCollectionsUtils.MapToArray(lst, Convert.ToString(_))

O! Thanks! It's work.

> I agree this shouldn't happen though :/ 

+1

Issue History
Date Modified  Username       Field                    Change              
======================================================================
03-19-07 23:36 VladD2         New Issue                                    
03-21-07 14:54 malekith       Note Added: 0001825                          
03-21-07 17:00 VladD2         Note Added: 0001826                          
======================================================================




More information about the bugs mailing list