[svn] r7396: nemerle/trunk/ncc: testsuite/negative/overloading.n
testsuite/positive/methods-1st-class-citi...
nazgul
svnadmin at nemerle.org
Wed Feb 7 18:42:11 CET 2007
Log:
Add compose and pipeline operators. Fix error message for incorrect overloads
Author: nazgul
Date: Wed Feb 7 18:42:09 2007
New Revision: 7396
Modified:
nemerle/trunk/ncc/testsuite/negative/overloading.n
nemerle/trunk/ncc/testsuite/positive/methods-1st-class-citizens.n
nemerle/trunk/ncc/typing/OverloadPossibility.n
Modified: nemerle/trunk/ncc/testsuite/negative/overloading.n
==============================================================================
--- nemerle/trunk/ncc/testsuite/negative/overloading.n (original)
+++ nemerle/trunk/ncc/testsuite/negative/overloading.n Wed Feb 7 18:42:09 2007
@@ -96,3 +96,11 @@
_ = Bug743 ("s"); // E: typing fails on amb
}
}
+
+public class FunctionsOverl {
+ f (_ : int) : void { }
+
+ foo () : void {
+ System.Console.WriteLine (f : double -> void); // void was expected to have type System.Double.*, while it has got int
+ }
+}
\ No newline at end of file
Modified: nemerle/trunk/ncc/testsuite/positive/methods-1st-class-citizens.n
==============================================================================
--- nemerle/trunk/ncc/testsuite/positive/methods-1st-class-citizens.n (original)
+++ nemerle/trunk/ncc/testsuite/positive/methods-1st-class-citizens.n Wed Feb 7 18:42:09 2007
@@ -7,6 +7,34 @@
public this (x : int) { val = x; }
}
+namespace ComposeAndPipeline {
+ using System.Console;
+ using System.Math;
+ using Nemerle.Builtins.Function; // this should not be necessary!
+
+ module Do {
+ public Run () : void {
+ def t2str(x : int * int) : string { x.ToString() }
+ def tup() : int * int { (1,2) }
+
+ WriteLine((tup >> t2str)());
+ def strlen(x : string) : int { x.Length }
+
+ WriteLine((tup >> t2str >> strlen)());
+
+ WriteLine((t2str >> strlen)(1,2));
+
+ def isqrt = Sqrt >> Ceiling; // instead of x => Ceiling(Sqrt(x))
+ WriteLine(isqrt(1235432));
+
+ WriteLine((Sqrt(1235432) |> Floor) : double);
+
+ Sqrt(1235432) |> Floor |> (WriteLine : double -> void);
+ }
+ }
+}
+
+
module M {
public Main () : void {
def l = [1,2,3];
@@ -16,6 +44,7 @@
List.Iter (l, a2.m);
a1.m2();
a2.m2();
+ ComposeAndPipeline.Do.Run ();
}
}
@@ -33,5 +62,11 @@
12
13
14
+(1, 2)
+6
+6
+1112
+1111
+1111
END-OUTPUT
*/
Modified: nemerle/trunk/ncc/typing/OverloadPossibility.n
==============================================================================
--- nemerle/trunk/ncc/typing/OverloadPossibility.n (original)
+++ nemerle/trunk/ncc/typing/OverloadPossibility.n Wed Feb 7 18:42:09 2007
@@ -394,6 +394,8 @@
ReportError (messenger,
$ "none of the overloads of $(hd.member.Name) is "
"possible:");
+ when (expected != null) {
+ def expectedDesc = expected.ToString ();
foreach (overload in overloads) {
solver.PushState ();
messenger.NeedMessage = true;
@@ -404,12 +406,13 @@
else
ReportError (messenger,
$ " $(overload.Member) was expected to have "
- "type $expected, while it has got $(res.Type)");
+ "type $expectedDesc, while it has got $(res.Type)");
}
solver.PopState ();
}
}
}
+ }
res
}
More information about the svn
mailing list