[nem-bug] [Nemerle 0000801]: Explicit conversion is too powerful for generics

feedback at nemerle.org feedback at nemerle.org
Sun Dec 3 19:24:18 CET 2006


The following issue has been SUBMITTED.
======================================================================
<http://nemerle.org/bugs/view.php?id=801> 
======================================================================
Reported By:                Evin Robertson
Assigned To:                
======================================================================
Project:                    Nemerle
Issue ID:                   801
Category:                   Compiler (type engine)
Reproducibility:            always
Severity:                   minor
Priority:                   normal
Status:                     new
======================================================================
Date Submitted:             12-03-2006 19:24 CET
Last Modified:              12-03-2006 19:24 CET
======================================================================
Summary:                    Explicit conversion is too powerful for generics
Description: 
The following code compiles, but it shouldn't:

public class GenericCast[F, T]
{
        private from : F;

        public this(from : F)
        {
                this.from = from
        }

        public Run() : T
        {
                from :> T
        }
}

public class A
{
        public static Main(_ : array[string]) : void
        {
                def c = GenericCast(100);
                _ = c.Run() : byte
        }
}


At runtime, a NullReferenceException is thrown in Run().  gmcs rejects the
equivalent C# program.  Nemerle should reject this program just as it does
the one with "from : T" instead of "from :> T".

======================================================================

Issue History
Date Modified  Username       Field                    Change              
======================================================================
12-03-06 19:24 Evin Robertson New Issue                                    
======================================================================




More information about the bugs mailing list