[svn] r7807: nemerle/trunk/ncc: testsuite/positive/block.n
typing/Typer2.n
divan
svnadmin at nemerle.org
Mon Oct 15 20:14:57 CEST 2007
Log:
Allow returning tuple from block without writing redundant braces. (fix #1037)
Author: divan
Date: Mon Oct 15 20:14:54 2007
New Revision: 7807
Modified:
nemerle/trunk/ncc/testsuite/positive/block.n
nemerle/trunk/ncc/typing/Typer2.n
Modified: nemerle/trunk/ncc/testsuite/positive/block.n
==============================================================================
--- nemerle/trunk/ncc/testsuite/positive/block.n (original)
+++ nemerle/trunk/ncc/testsuite/positive/block.n Mon Oct 15 20:14:54 2007
@@ -184,12 +184,21 @@
}
}
+ // bug/feature #1037
+ def foo4 () : int * int
+ {
+ res : {
+ res (1, 2)
+ }
+ }
+
System.Console.WriteLine (foo (true));
System.Console.WriteLine (foo (false));
System.Console.WriteLine (foo2 (true));
System.Console.WriteLine (foo2 (false));
System.Console.WriteLine (foo3 (true));
System.Console.WriteLine (foo3 (false));
+ System.Console.WriteLine (foo4 ());
}
}
@@ -211,5 +220,6 @@
2
1
2
+(1, 2)
END-OUTPUT
*/
Modified: nemerle/trunk/ncc/typing/Typer2.n
==============================================================================
--- nemerle/trunk/ncc/typing/Typer2.n (original)
+++ nemerle/trunk/ncc/typing/Typer2.n Mon Oct 15 20:14:54 2007
@@ -718,7 +718,13 @@
TExpr.LocalRef (result_decl),
parm.expr),
Walk (ctx, TExpr.Goto (ty, label, 1)))
- | _ => Util.ice ()
+ | _ =>
+ result_decl.Type.ForceUnify (MType.Tuple (parms.Map (_.required_type)));
+ TExpr.Sequence (ty,
+ TExpr.Assign (InternalType.Void,
+ TExpr.LocalRef (result_decl),
+ TExpr.Tuple (result_decl.Type, parms.Map (_.expr))),
+ Walk (ctx, TExpr.Goto (ty, label, 1)))
}
}
More information about the svn
mailing list