[svn] r7407: nemerle/trunk/ncc: testsuite/positive/generics.n
typing/TyVarEnv.n
VladD2
svnadmin at nemerle.org
Mon Feb 12 02:40:31 CET 2007
Log:
1. Fix 875.
2. Fix error message formating.
3. Arr test for bug 888.
Author: VladD2
Date: Mon Feb 12 02:40:29 2007
New Revision: 7407
Modified:
nemerle/trunk/ncc/testsuite/positive/generics.n
nemerle/trunk/ncc/typing/TyVarEnv.n
Modified: nemerle/trunk/ncc/testsuite/positive/generics.n
==============================================================================
--- nemerle/trunk/ncc/testsuite/positive/generics.n (original)
+++ nemerle/trunk/ncc/testsuite/positive/generics.n Mon Feb 12 02:40:29 2007
@@ -178,6 +178,12 @@
}
}
+public module Bug888
+{
+ public Foo[T,S,U](_x : T) : void where S : T where U : S, T
+ {
+ }
+}
/*
BEGIN-OUTPUT
System.Collections.Generic.List`1[System.Int32]
Modified: nemerle/trunk/ncc/typing/TyVarEnv.n
==============================================================================
--- nemerle/trunk/ncc/typing/TyVarEnv.n (original)
+++ nemerle/trunk/ncc/typing/TyVarEnv.n Mon Feb 12 02:40:29 2007
@@ -434,7 +434,7 @@
constraints [tv.id] = (special, subtype);
| None =>
- Message.Error ("unbound type variable `$(c.tyvar)' in constraint")
+ Message.Error ($"unbound type variable `$(c.tyvar)' in constraint")
}
}
@@ -444,11 +444,11 @@
{
def graph = Hashtable();
- def tryFindCyclicConstraint (tyRef)
- {
foreach (tv : StaticTyVar in tyParams)
graph[tv.id] = false; // reset 'visited' flags
+ def tryFindCyclicConstraint (tyRef)
+ {
def scan (tyRef, path = []) // travers constraint dependency path
{
mutable visited;
@@ -458,10 +458,10 @@
tyRef.Name :: path // and already visited
else
{ // first visit
- graph[tyRef.id] = true; // mark type parametr as visited
mutable constraint;
if (constraints.TryGetValue(tyRef.id, out constraint))
{ // type parametr have constraints... foreach constraint...
+ graph[tyRef.id] = true; // mark type parametr as visited
foreach (TyVarRef (subTyRef) in constraint[1])
{
def res = scan(subTyRef, path);
@@ -469,7 +469,12 @@
Nemerle.Imperative.Return (tyRef.Name :: res);
}
- if (path.IsEmpty) [] else tyRef.Name :: path
+ if (path.IsEmpty)
+ {
+ graph[tyRef.id] = false;
+ []
+ }
+ else tyRef.Name :: path
}
else path
}
@@ -484,7 +489,7 @@
def tyParam = path.Head;
cyclicConstraints ::= tyRef;
Message.Error ( // try find location of type parametr
- match (tp.tyvars.Find(x => x.ToString() == tyParam)) {
+ match (tp.tyvars.Find (x => x.ToString () == tyParam)) {
| Some(name) => name.Location
| _ => Location.Default
},
@@ -493,7 +498,8 @@
}
foreach (tv : StaticTyVar in tyParams)
- tryFindCyclicConstraint(tv);
+ unless (graph[tv.id])
+ tryFindCyclicConstraint (tv);
}
unless (tyParams.IsEmpty)
More information about the svn
mailing list