[nem-bug] [Nemerle 0000846]: Do not allow to cast array[T] to
array[S], if T is not known to be a reference type
feedback at nemerle.org
feedback at nemerle.org
Sun Jan 28 10:23:43 CET 2007
A NOTE has been added to this issue.
======================================================================
<http://nemerle.org/bugs/view.php?id=846>
======================================================================
Reported By: nikov
Assigned To:
======================================================================
Project: Nemerle
Issue ID: 846
Category: Code Completion Engine
Reproducibility: always
Severity: major
Priority: normal
Status: new
======================================================================
Date Submitted: 01-28-2007 10:03 CET
Last Modified: 01-28-2007 10:23 CET
======================================================================
Summary: Do not allow to cast array[T] to array[S], if T is
not known to be a reference type
Description:
Do not allow to cast array[T] to array[S], if T is not known to be a
reference type (and T, S are different types). Consider the following
code:
using System.Collections.Generic;
module A {
Foo[T,S](x : array[T]) : array[S] where T : S {
x :> array[S]
}
Main() : void {
_ = Foo.[int,object](array[1,2,3]);
}
}
Ncc compiles this successfully, but the program fails at runtime. This
could be prevented at compile time, if Nemerle required T to be known to
be a reference type in order to allow cast between arrays (as, for
instance, C# does).
using System.Collections.Generic;
module A {
Foo[T,S](x : array[T]) : array[S] where T : class, S {
x :> array[S]
}
}
======================================================================
----------------------------------------------------------------------
nikov - 01-28-07 10:23
----------------------------------------------------------------------
Sorry, category should be '[Nemerle] Compiler', not 'Completion Engine'.
Issue History
Date Modified Username Field Change
======================================================================
01-28-07 10:03 nikov New Issue
01-28-07 10:23 nikov Note Added: 0001653
======================================================================
More information about the bugs
mailing list