[Mono-bugs] [Bug 430508] New: [Regression] TypeBuilder. MakeGenericType does not handle enum type arguments

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Sun Sep 28 16:07:55 EDT 2008


https://bugzilla.novell.com/show_bug.cgi?id=430508


           Summary: [Regression] TypeBuilder.MakeGenericType does not handle
                    enum type arguments
           Product: Mono: Class Libraries
           Version: 2.0
          Platform: x86-64
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: System
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: evinrobertson at verizon.net
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---


Description of Problem:

The Mono 2.0 pre-release changes enum type arguments into their underlying type
when used as type arguments.  This didn't happen in Mono 1.9.1.  I can see this
problem when using Nemerle (r8044) to compile the following problem:

public enum E {
    | Red
    | Green
    | Blue
}

public module X {
    public F() : string * E
    {
        ("hello", E.Blue)
    }

    public Main(_ : array[string]) : int
    {
        def (s, e) = F();
        System.Console.WriteLine($"$s, $e");
        0
    }
}


X.F above returns a Tuple<string, E>.  In Mono 1.9.1, this compiles fine, but
in Mono 2.0, X.F is compiled to return a Tuple<string, int32>.  This causes an
invalid IL exception to be thrown.



Steps to reproduce the problem:
1. Compile the above problem using Mono 2.0 and Nemerle r8044.
2. Run it.
3. Run monodis on it.
4. Repeat with Mono 1.9.1.


Actual Results:

It crashes with:

Unhandled Exception: System.InvalidProgramException: Invalid IL code in X:Main
(string[]): IL_0005: stloc.0   

Looking at the disassembly shows that F is not compiled correctly:

    .method public static  hidebysig 
           default valuetype [Nemerle]Nemerle.Builtins.Tuple`2<string, int32> F
()  cil managed 


Expected Results:

It should work the same as it does in Mono 1.9.1.


How often does this happen? 

Every time.  Also, this prevents compiling versions of Nemerle >= r8045.


Additional Information:

I can fix this by modifying TypeBuilder.UnderlyingSystemType to comment out the
special enum handling:

public override Type UnderlyingSystemType {
        get {
                if (is_created)
                        return created.UnderlyingSystemType;

/*
                if (IsEnum && !IsCompilerContext) {
                        if (underlying_type != null)
                                return underlying_type;
                        throw new InvalidOperationException (
                                "Enumeration type is not defined.");
                }
*/
                return this;
        }
}


-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.


More information about the mono-bugs mailing list