[nem-bug] [Nemerle 0000841]: Nemerle compiler does not warn if
there are polymorphic types with too deep inheritance tree
feedback at nemerle.org
feedback at nemerle.org
Fri Jan 26 22:00:35 CET 2007
A NOTE has been added to this issue.
======================================================================
<http://nemerle.org/bugs/view.php?id=841>
======================================================================
Reported By: nikov
Assigned To:
======================================================================
Project: Nemerle
Issue ID: 841
Category: Compiler
Reproducibility: always
Severity: minor
Priority: normal
Status: new
======================================================================
Date Submitted: 01-26-2007 20:19 CET
Last Modified: 01-26-2007 22:00 CET
======================================================================
Summary: Nemerle compiler does not warn if there are
polymorphic types with too deep inheritance tree
Description:
Nemerle compiler does not warn if there are polymorphic types with too deep
inheritance tree.
class A[T] { }
class B[T] : A[B[B[T]]] { }
_ = null : B[int]
This code produces System.TypeLoadException: A generic instantiation for
type
'A`1' from assembly 'NemerleProject, Version=1.0.0.0, Culture=neutral,
PublicKey
Token=null' was too deep. Is this generic type defined or used
recursively?
at _N_AutoModule.Main()
See Ecma-335, 9.2 Generics and recursive inheritance graphs
======================================================================
----------------------------------------------------------------------
nazgul - 01-26-07 21:41
----------------------------------------------------------------------
I try with
class A[T] { }
class B[T] : A[B[B[B[B[B[B[B[B[B[T]]]]]]]]]] { }
_ = null : B[B[B[int]]]
and it still works for me. Are you sure this is not a runtime issue
(recursive increase of generic type size)?
----------------------------------------------------------------------
nazgul - 01-26-07 21:48
----------------------------------------------------------------------
Ok, I can see in the spec that this should be disallowed at all...
----------------------------------------------------------------------
nazgul - 01-26-07 22:00
----------------------------------------------------------------------
Hehe, this is also not spotted by C# compiler:
class B<U> {}
class A<T> : B<A<A<T>>> {}
Reading the spec I can see that computing this verification graph is quite
costly operation (you should consider all generic types in program and
references libraries!). This is probably why C# compiler does not do
this... I guess we won't support it for the same reason and additionally
as we have no much resources in development and there are so much more
important tasks...
Issue History
Date Modified Username Field Change
======================================================================
01-26-07 20:19 nikov New Issue
01-26-07 21:41 nazgul Note Added: 0001649
01-26-07 21:48 nazgul Note Added: 0001650
01-26-07 22:00 nazgul Note Added: 0001651
======================================================================
More information about the bugs
mailing list