[nem-bug] [Nemerle 0000540]: Using void as generic argument causes invalid IL

feedback at nemerle.org feedback at nemerle.org
Sun Oct 2 21:19:38 CEST 2005


The following issue has been RESOLVED.
======================================================================
<http://nemerle.org/bugs/view.php?id=540> 
======================================================================
Reported By:                steffen
Assigned To:                malekith
======================================================================
Project:                    Nemerle
Issue ID:                   540
Category:                   Compiler
Reproducibility:            always
Severity:                   minor
Priority:                   normal
Status:                     resolved
Resolution:                 fixed
Fixed in Version:           
======================================================================
Date Submitted:             10-01-2005 17:39 CEST
Last Modified:              10-02-2005 21:19 CEST
======================================================================
Summary:                    Using void as generic argument causes invalid IL
Description: 
The following code compiles but generates invalid IL:

module X {
    f['a] (_:'a):void {}

    Main():void {
        f( () );
    }
}

The following code however compiles and runs:

module X {
    f['a] ():'a { Nemerle.Extensions.DefaultValue ('a) }

    Main():void {
        f.[void]();
    }
}

(The second case is like Util.ice in the compiler. It is translated to _ =
f.[object]() .)

The CIL spec says:
The following kinds of type cannot be used as arguments in instantiations
(of generic types or methods):
...
void (e.g., List<System.Void> is invalid)


So either the compiler should complain about using void as type argument
or should translate it to something different (like System.Object, as
already done in the second case).
======================================================================

----------------------------------------------------------------------
 nazgul - 10-01-05 18:07 
----------------------------------------------------------------------
Yes, the void useage in second case was specially workarounded in IL
emission to generate Object instead of void - this is because it makes
perfect sense to use void as generic argument, especially for return types
of functions. We even reported a suggestion to change CIL spec:

http://lab.msdn.microsoft.com/productfeedback/viewfeedback.aspx?feedbackid=01607634-64fa-4823-bf68-05a48bf54295

but it seems it won't get into spec anytime in future.

So, this is just a bug in our IL emission, we should workaround also this
case.

----------------------------------------------------------------------
 malekith - 10-02-05 21:19 
----------------------------------------------------------------------
Resolved on trunk, r5792.

Issue History
Date Modified  Username       Field                    Change              
======================================================================
10-01-05 17:39 steffen        New Issue                                    
10-01-05 18:07 nazgul         Note Added: 0000984                          
10-01-05 18:07 nazgul         Status                   new => confirmed    
10-01-05 18:07 nazgul         Description Updated                          
10-02-05 21:19 malekith       Status                   confirmed => resolved
10-02-05 21:19 malekith       Resolution               open => fixed       
10-02-05 21:19 malekith       Assigned To               => malekith        
10-02-05 21:19 malekith       Note Added: 0000986                          
======================================================================




More information about the bugs mailing list