[svn] r7631: nemerle/trunk/ncc: generation/Typer3.n
testsuite/positive/yield.n
malekith
svnadmin at nemerle.org
Mon Apr 30 11:57:04 CEST 2007
Log:
Fix the problem with _N_yielding_function in the closure. Fixes #991.
Author: malekith
Date: Mon Apr 30 11:57:03 2007
New Revision: 7631
Modified:
nemerle/trunk/ncc/generation/Typer3.n
nemerle/trunk/ncc/testsuite/positive/yield.n
Modified: nemerle/trunk/ncc/generation/Typer3.n
==============================================================================
--- nemerle/trunk/ncc/generation/Typer3.n (original)
+++ nemerle/trunk/ncc/generation/Typer3.n Mon Apr 30 11:57:03 2007
@@ -459,6 +459,7 @@
decl.UseFrom (current_local_fun);
PlainRef (decl)
} else {
+ def hd = if (hd.name == "_N_yielding_function") hd.decl.DefinedIn else hd;
Util.cassert (closure_fields != null);
Util.cassert (closure_fields.Contains (hd.id), $ "no closure for $(hd.name) from $(current_local_fun.name)");
def field = closure_fields [hd.id];
Modified: nemerle/trunk/ncc/testsuite/positive/yield.n
==============================================================================
--- nemerle/trunk/ncc/testsuite/positive/yield.n (original)
+++ nemerle/trunk/ncc/testsuite/positive/yield.n Mon Apr 30 11:57:03 2007
@@ -23,6 +23,29 @@
}
}
+module Bug991 {
+ public Go () : void {
+ foreach (_ in E(3)) { }
+ foreach (_ in E2()) { }
+ }
+ q (f : int->int) : void {
+ System.Console.WriteLine(f(1));
+ System.Console.WriteLine(f(2));
+ }
+ E (qq : int) : System.Collections.Generic.IEnumerable[int]
+ {
+ def x = 42;
+ q (z => z+x*qq);
+ yield 1;
+ }
+ E2 () : System.Collections.Generic.IEnumerable[int]
+ {
+ def x = 42;
+ q (z => z+x);
+ yield 1;
+ }
+}
+
[Record]
class D : IEnumerable [string]
{
@@ -167,6 +190,8 @@
System.Console.WriteLine ($[x | x in Bug756.GetToken()]);
+Bug991.Go();
+
/*
BEGIN-OUTPUT
42
@@ -228,5 +253,9 @@
Outer finally
Outer block
[43, 44, 45, 46]
+127
+128
+43
+44
END-OUTPUT
*/
More information about the svn
mailing list