[nem-bug] [Nemerle 0001052]: Compiler loose a generic type, causing a program to crash.

feedback at nemerle.org feedback at nemerle.org
Fri Oct 12 20:41:36 CEST 2007


The following issue requires your FEEDBACK.
======================================================================
<http://nemerle.org/bugs/view.php?id=1052> 
======================================================================
Reported By:                hi_octane
Assigned To:                divan
======================================================================
Project:                    Nemerle
Issue ID:                   1052
Category:                   Language Feature
Reproducibility:            always
Severity:                   major
Priority:                   normal
Status:                     feedback
======================================================================
Date Submitted:             10-02-2007 10:30 CEST
Last Modified:              10-12-2007 20:41 CEST
======================================================================
Summary:                    Compiler loose a generic type, causing a program to
crash.
Description: 
A common C# pattern allows generic-based implementation of static methods
and properties with a common abstract base class. Nemerle compiles this
sample incorrectly, finally trying to create an instance of the abstract
class during runtime (even ignoring the new() constraint).
======================================================================

----------------------------------------------------------------------
 divan - 10-09-07 19:29 
----------------------------------------------------------------------
Fixed new() constraint on r7803, proper error is generated for third case.

Fixing base class generic parameters won't be that easy, class member
lookup doesn't know anything about generics :( but i'll try to ;)

----------------------------------------------------------------------
 divan - 10-12-07 20:40 
----------------------------------------------------------------------
Whoops there is a surprise: .net states that static members are not
inherited, so it's a feature indeed, which differs from C#.
C#:
class A<T> { protected static void f(T a) {} };
class B : A<int> {
 public static void Main() {
  f(1.1); //Error
 }
}
Nemerle:
class A[T] { protected static f (_ : T) : void {} }
class B : A[int] {
 public static Main () : void {
  f (1.1) //OK, and generated code is Ok
 }
}

P.S. but maybe nemerle behaviour should be changed, any thoughts?

Issue History
Date Modified  Username       Field                    Change              
======================================================================
10-02-07 10:30 hi_octane      New Issue                                    
10-02-07 10:30 hi_octane      File Added: GenericsInheritanceBug.n              
     
10-02-07 18:46 divan          Issue Monitored: divan                       
10-09-07 04:27 divan          Status                   new => assigned     
10-09-07 04:27 divan          Assigned To               => divan           
10-09-07 19:29 divan          Note Added: 0001959                          
10-12-07 20:40 divan          Note Added: 0001960                          
10-12-07 20:41 divan          Status                   assigned => feedback
10-12-07 20:41 divan          Category                 Compiler (type engine) =>
Language Feature
======================================================================




More information about the bugs mailing list