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

feedback at nemerle.org feedback at nemerle.org
Sat Oct 1 18:07:13 CEST 2005


The following issue has been CONFIRMED.
======================================================================
<https://nemerle.org/bugs/view.php?id=540> 
======================================================================
Reported By:                steffen
Assigned To:                
======================================================================
Project:                    Nemerle
Issue ID:                   540
Category:                   Compiler
Reproducibility:            always
Severity:                   minor
Priority:                   normal
Status:                     confirmed
======================================================================
Date Submitted:             10-01-2005 17:39 CEST
Last Modified:              10-01-2005 18:07 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.

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                          
======================================================================




More information about the bugs mailing list