[svn] r6858: nemerle/trunk/ncc: testsuite/negative/tyenf.n typing/MType.n typing/TyVar.n

malekith svnadmin at nemerle.org
Thu Nov 9 09:29:32 CET 2006


Log:
Properly save error in case array type is compared against generic, single argument type, not being IList or the like. Resolves #753.

Author: malekith
Date: Thu Nov  9 09:29:31 2006
New Revision: 6858

Modified:
   nemerle/trunk/ncc/testsuite/negative/tyenf.n
   nemerle/trunk/ncc/typing/MType.n
   nemerle/trunk/ncc/typing/TyVar.n

Modified: nemerle/trunk/ncc/testsuite/negative/tyenf.n
==============================================================================
--- nemerle/trunk/ncc/testsuite/negative/tyenf.n	(original)
+++ nemerle/trunk/ncc/testsuite/negative/tyenf.n	Thu Nov  9 09:29:31 2006
@@ -11,6 +11,12 @@
 enum Fruit { | Apple | Orange };
 
 module M1 {
+  // bug #753
+  Foo() : list[string] // E: array .* is not a subtype of list\[string\]
+  {
+     if (true) array(0) else null 
+  }
+
   f () : void {
     def f1 (x) { printf ("%s\n", x) };
     printf ("%d", f1 ("foo")); // E: expected int.*, got void in type-enforced expression

Modified: nemerle/trunk/ncc/typing/MType.n
==============================================================================
--- nemerle/trunk/ncc/typing/MType.n	(original)
+++ nemerle/trunk/ncc/typing/MType.n	Thu Nov  9 09:29:31 2006
@@ -29,6 +29,7 @@
 using Nemerle.Compiler.SolverMacros;
 using Nemerle.Collections;
 using Nemerle.Utility;
+using Nemerle.Logging;
 
 namespace Nemerle.Compiler 
 {
@@ -249,6 +250,7 @@
     /** Enforce [this] to be subtype of [t]. */
     public override Require (t : MType) : bool
     {
+      log (SOLVER, $"MType.Req: $this <: $t");
       def s = Manager.Solver;
 
       def covariant_check (t, a1, a2) {
@@ -324,11 +326,12 @@
         //| (Class (tc, _), Void) when tc.Equals (InternalType.Void_tc)
         | (Void, Void) => true
 
-        | (Array (t, n), Class (tc, [t'])) =>
+        | (Array (t, n), Class (tc, [t'])) when
          (tc.Equals (InternalType.Generic_IEnumerable_tc) ||
           tc.Equals (InternalType.Generic_IList_tc) ||
           tc.Equals (InternalType.Generic_ICollection_tc) ||
-          tc.Equals (InternalType.GetArrayType (n))) && t.Unify (t')
+              tc.Equals (InternalType.GetArrayType (n))) =>
+          t.Unify (t')
       
         | (Array, Class (_, []) as ct) =>
           InternalType.Array.Require (ct)

Modified: nemerle/trunk/ncc/typing/TyVar.n
==============================================================================
--- nemerle/trunk/ncc/typing/TyVar.n	(original)
+++ nemerle/trunk/ncc/typing/TyVar.n	Thu Nov  9 09:29:31 2006
@@ -865,10 +865,7 @@
             _ = high.Require (new_bound);
           else {
             high.WillWrite ();
-            whenlogging (SOLVER) {
-              //def tv = if (high.lower_bound == null) "(null)" else high.lower_bound.ToString ();
-              //Message.Debug ($"new bound $tv * $low  = $new_bound");
-            }
+            log (SOLVER, $ "new_bound=$new_bound ($(high.lower_bound) X $low) $LocalError");
             when (high.lower_bound == null || 
                   !new_bound.Equals (high.lower_bound)) {
               high.lower_bound = new_bound;
@@ -880,8 +877,11 @@
         unless (high.IsFixed) {
           def high = high.Self;
           when (high.upper_bound != null &&
-                high.lower_bound != null)
+                high.lower_bound != null) {
+            log (SOLVER, $"Require: $(high.upper_bound) <: $(high.lower_bound)");
             _ = high.upper_bound.Require (high.lower_bound);
+            log (SOLVER, $"Require: $(high.upper_bound) <: $(high.lower_bound) --> $LocalError");
+          }
           
           def high = high.Self;
 



More information about the svn mailing list