Merge: More keepgoing
authorJean Privat <jean@pryen.org>
Sat, 7 Nov 2015 17:38:47 +0000 (12:38 -0500)
committerJean Privat <jean@pryen.org>
Sat, 7 Nov 2015 17:38:47 +0000 (12:38 -0500)
Another small serie about robustness.

Now all files in tests (including alts), except one, do not make `nipick` crash.
This should improve the quality of error messages in vim.

Pull-Request: #1816
Reviewed-by: Alexis Laferrière <alexis.laf@xymus.net>

60 files changed:
src/compiler/abstract_compiler.nit
src/loader.nit
src/modelbuilder.nit
src/modelize/modelize_class.nit
src/nit.nit
src/nitvm.nit
src/semantize/typing.nit
src/toolcontext.nit
tests/error_array_ambig.nit
tests/error_attr_2def.nit
tests/error_attr_assign.nit
tests/error_cons_arity.nit
tests/error_cons_arity2.nit
tests/error_constraint.nit
tests/error_decl_type_var.nit
tests/error_for_coll.nit
tests/error_formal.nit
tests/error_formal_name.nit
tests/error_fun_ret.nit
tests/error_fun_ret2.nit
tests/error_fun_ret3.nit
tests/error_fun_ret4.nit
tests/error_fun_ret5.nit
tests/error_gen_f_inh_clash.nit
tests/error_if_bool.nit
tests/error_inh_clash.nit
tests/error_inh_clash2.nit
tests/error_inh_clash3.nit
tests/error_inh_clash4.nit
tests/error_inh_loop.nit
tests/error_kern_attr_any.nit
tests/error_kern_attr_int.nit
tests/error_left_bool.nit
tests/error_loop_bool_while.nit
tests/error_meth_2def.nit
tests/error_meth_2def2.nit
tests/error_redef3.nit
tests/error_redef4.nit
tests/error_redef_class.nit
tests/error_ref_attr.nit
tests/error_ref_fun.nit
tests/error_ref_param.nit
tests/error_ref_proc.nit
tests/error_ref_ret.nit
tests/error_ret_fun.nit
tests/error_ret_type.nit
tests/error_right_bool.nit
tests/error_signature.nit
tests/error_spe_attr.nit
tests/error_spe_fun.nit
tests/error_spe_param.nit
tests/error_spe_param2.nit
tests/error_spe_proc.nit
tests/error_spe_ret.nit
tests/error_super_none.nit
tests/error_type_not_ok.nit
tests/error_type_not_ok2.nit
tests/error_type_not_ok3.nit
tests/error_type_not_ok4.nit
tests/error_unk_class.nit

index 9584179..de68957 100644 (file)
@@ -3894,11 +3894,7 @@ end
 # Here we load an process all modules passed on the command line
 var mmodules = modelbuilder.parse(arguments)
 
-if mmodules.is_empty then
-       toolcontext.check_errors
-       toolcontext.errors_info
-       if toolcontext.error_count > 0 then exit(1) else exit(0)
-end
+if mmodules.is_empty then toolcontext.quit
 
 modelbuilder.run_phases
 
index c80b6dc..b3485ed 100644 (file)
@@ -104,7 +104,7 @@ redef class ModelBuilder
 
                if toolcontext.opt_only_parse.value then
                        self.toolcontext.info("*** ONLY PARSE...", 1)
-                       exit(0)
+                       self.toolcontext.quit
                end
 
                return mmodules.to_a
@@ -199,7 +199,7 @@ redef class ModelBuilder
 
                if toolcontext.opt_only_parse.value then
                        self.toolcontext.info("*** ONLY PARSE...", 1)
-                       exit(0)
+                       self.toolcontext.quit
                end
 
                return mmodules.to_a
index 00e41b5..671fcd0 100644 (file)
@@ -100,7 +100,7 @@ redef class ModelBuilder
 
                if toolcontext.opt_only_metamodel.value then
                        self.toolcontext.info("*** ONLY METAMODEL", 1)
-                       exit(0)
+                       toolcontext.quit
                end
        end
 
index b3ab0bb..fa1fddb 100644 (file)
@@ -301,7 +301,6 @@ redef class ModelBuilder
        # REQUIRE: classes of imported modules are already build. (let `phase` do the job)
        private fun build_classes(nmodule: AModule)
        do
-               var errcount = toolcontext.error_count
                # Force building recursively
                if nmodule.build_classes_is_done then return
                nmodule.build_classes_is_done = true
@@ -312,8 +311,6 @@ redef class ModelBuilder
                        if nimp != null then build_classes(nimp)
                end
 
-               if errcount != toolcontext.error_count then return
-
                # Create all classes
                # process AStdClassdef before so that non-AStdClassdef classes can be attached to existing ones, if any
                for nclassdef in nmodule.n_classdefs do
@@ -325,8 +322,6 @@ redef class ModelBuilder
                        self.build_a_mclass(nmodule, nclassdef)
                end
 
-               if errcount != toolcontext.error_count then return
-
                # Create all classdefs
                for nclassdef in nmodule.n_classdefs do
                        if not nclassdef isa AStdClassdef then continue
@@ -337,29 +332,21 @@ redef class ModelBuilder
                        self.build_a_mclassdef(nmodule, nclassdef)
                end
 
-               if errcount != toolcontext.error_count then return
-
                # Create inheritance on all classdefs
                for nclassdef in nmodule.n_classdefs do
                        self.collect_a_mclassdef_inheritance(nmodule, nclassdef)
                end
 
-               if errcount != toolcontext.error_count then return
-
                # Create the mclassdef hierarchy
                for mclassdef in mmodule.mclassdefs do
                        mclassdef.add_in_hierarchy
                end
 
-               if errcount != toolcontext.error_count then return
-
                # Check inheritance
                for nclassdef in nmodule.n_classdefs do
                        self.check_supertypes(nmodule, nclassdef)
                end
 
-               if errcount != toolcontext.error_count then return
-
                # Check unchecked ntypes
                for nclassdef in nmodule.n_classdefs do
                        if nclassdef isa AStdClassdef then
@@ -383,8 +370,6 @@ redef class ModelBuilder
                        end
                end
 
-               if errcount != toolcontext.error_count then return
-
                # Check clash of ancestors
                for nclassdef in nmodule.n_classdefs do
                        var mclassdef = nclassdef.mclassdef
@@ -405,13 +390,11 @@ redef class ModelBuilder
                        end
                end
 
-               if errcount != toolcontext.error_count then return
-
                # TODO: Check that the super-class is not intrusive
 
                # Check that the superclasses are not already known (by transitivity)
                for nclassdef in nmodule.n_classdefs do
-                       if not nclassdef isa AStdClassdef then continue
+                       if not nclassdef isa AStdClassdef or nclassdef.is_broken then continue
                        var mclassdef = nclassdef.mclassdef
                        if mclassdef == null then continue
 
index 196961d..9410b4d 100644 (file)
@@ -70,7 +70,7 @@ end
 
 modelbuilder.run_phases
 
-if toolcontext.opt_only_metamodel.value then exit(0)
+if toolcontext.opt_only_metamodel.value then toolcontext.quit
 
 var mainmodule = toolcontext.make_main_module(mmodules)
 
index 088cd92..e81b20d 100644 (file)
@@ -45,7 +45,7 @@ var mmodules = modelbuilder.parse([progname])
 mmodules.add_all modelbuilder.parse(opt_mixins.value)
 modelbuilder.run_phases
 
-if toolcontext.opt_only_metamodel.value then exit(0)
+if toolcontext.opt_only_metamodel.value then toolcontext.quit
 
 var mainmodule: nullable MModule
 
index 8a23a73..b4599d0 100644 (file)
@@ -117,6 +117,7 @@ private class TypeVisitor
                        #node.debug("Unsafe typing: expected {sup}, got {sub}")
                        return sup
                end
+               if sup isa MBottomType then return null # Skip error
                if sub.need_anchor then
                        var u = anchor_to(sub)
                        self.modelbuilder.error(node, "Type Error: expected `{sup}`, got `{sub}: {u}`.")
@@ -1134,6 +1135,7 @@ redef class AForExpr
                        var mtype = v.visit_expr(g.n_expr)
                        if mtype == null then return
                        g.do_type_iterator(v, mtype)
+                       if g.is_broken then is_broken = true
                end
 
                v.visit_stmt(n_block)
index bdd6338..850781e 100644 (file)
@@ -169,6 +169,16 @@ class ToolContext
                return tags.has("all") or tags.has(tag)
        end
 
+       # Output all current stacked messages, total and exit the program
+       #
+       # If there is no error, exit with 0, else exit with 1.
+       fun quit
+       do
+               check_errors
+               errors_info
+               if error_count > 0 then exit(1) else exit(0)
+       end
+
        # Output all current stacked messages
        #
        # Return true if no errors occurred.
index 8ef8529..ef4beb6 100644 (file)
@@ -15,3 +15,4 @@
 # limitations under the License.
 
 var i = [4, '4']
+i.first.output
index e10ed39..d7d7122 100644 (file)
@@ -18,3 +18,6 @@ class A
        var toto: Int
        var toto: Object
 end
+
+var a = new A
+a.toto.output
index 173d9b5..8265b99 100644 (file)
@@ -21,3 +21,6 @@ class A
                _toto = 't'
        end
 end
+
+var a = new A(1)
+a.m
index 6c6ee71..3f1cede 100644 (file)
@@ -18,3 +18,6 @@ class C[E]
 end
 class C[E: Object, F: Object]
 end
+
+var c = new C
+c.output
index b1f4c5d..9dd4ccd 100644 (file)
@@ -19,3 +19,6 @@ end
 
 class A[E: Object]
 end
+
+var a = new A
+a.output
index 8ed9abf..61c1fa7 100644 (file)
@@ -19,3 +19,6 @@ class A
 end
 class A[E: Object]
 end
+
+var a = new A
+a.output
index 89d8bfe..0d31269 100644 (file)
@@ -15,3 +15,4 @@
 # limitations under the License.
 
 var i: Int = '4'
+i.output
index 42380aa..008d626 100644 (file)
@@ -15,4 +15,5 @@
 # limitations under the License.
 
 for i in 5 do
+       i.output
 end
index 13a16b5..a45a57a 100644 (file)
@@ -17,3 +17,6 @@
 class A[T]
        var k: T[Int]
 end
+
+var a = new A[Object]
+a.output
index be27718..9ebbb23 100644 (file)
@@ -17,3 +17,5 @@ import kernel
 class G[Foo]
        type Bar: Object
 end
+
+var g = new G[Object]
index 8744a8e..6cb6330 100644 (file)
@@ -17,3 +17,5 @@
 fun toto: Int
 do
 end
+
+toto.output
index 7f09bfc..d9beb18 100644 (file)
@@ -20,3 +20,5 @@ do
                return 0
        end
 end
+
+toto.output
index 0825cb5..bba3eaf 100644 (file)
@@ -21,3 +21,5 @@ do
                return 1
        end
 end
+
+toto.output
index 9d74ff0..bccb2e8 100644 (file)
@@ -21,3 +21,5 @@ do
                return 1
        end
 end
+
+toto.output
index b4173ec..065533e 100644 (file)
@@ -20,3 +20,5 @@ do
                return 1
        end
 end
+
+toto.output
index 6ea638d..12d8a0a 100644 (file)
@@ -20,3 +20,6 @@ class G3
        super G1
        super G2
 end
+
+var g = new G3
+g.output
index 17b0bf8..8380fa6 100644 (file)
@@ -15,4 +15,5 @@
 # limitations under the License.
 
 if 5 then
+       1.output
 end
index f9e31b5..bc04cd4 100644 (file)
@@ -18,3 +18,6 @@ class A
        super Array[Int]
        super Array[Char]
 end
+
+var a = new A
+a.output
index a66d081..2c1cb4a 100644 (file)
@@ -24,3 +24,6 @@ class C
        super A
        super B
 end
+
+var c = new C
+c.output
index f205c7a..8c720d8 100644 (file)
@@ -24,3 +24,6 @@ class C
        super A[Int]
        super B[Char]
 end
+
+var c = new C
+c.output
index 8f9928f..63d05e7 100644 (file)
@@ -16,3 +16,6 @@ class A[E, F]
        super Array[E]
        super List[F]
 end
+
+var a = new A[Int, Int]
+a.output
index 0e778f9..0f639a8 100644 (file)
@@ -27,3 +27,6 @@ end
 class C
        super A
 end
+
+var a = new A
+a.output
index e45209c..76d3763 100644 (file)
@@ -17,3 +17,5 @@
 redef class Object
        var toto: Bool
 end
+
+toto.output
index 5a0ea55..7056d6d 100644 (file)
@@ -17,3 +17,5 @@
 redef class Int
        var toto: Object
 end
+
+1.toto.output
index 0a2690a..dc9bcd8 100644 (file)
@@ -15,4 +15,5 @@
 # limitations under the License.
 
 if 5 and true then
+       1.output
 end
index d53eb60..74394dd 100644 (file)
@@ -15,4 +15,5 @@
 # limitations under the License.
 
 while 5 do
+       1.output
 end
index 140089c..7f41160 100644 (file)
@@ -18,3 +18,6 @@ class A
        fun toto(a: Int) do end
        fun toto(a: Char) do end
 end
+
+var a = new A
+a.toto(1)
index 8e10ea6..48c63a4 100644 (file)
@@ -18,3 +18,6 @@ class A
        fun toto(a: Int) do end
        fun toto(a: Int): Int do return 0 end
 end
+
+var a = new A
+a.toto(1).output
index b7075d6..eeeda92 100644 (file)
@@ -15,3 +15,5 @@
 class A end
 class A end
 
+var a = new A
+a.output
index cf2d3c9..8b2f3f1 100644 (file)
@@ -17,3 +17,5 @@ import error_redef4_base
 redef class A end
 redef class A end
 
+var a = new A
+a.output
index 87277d0..05363db 100644 (file)
@@ -15,3 +15,6 @@
 import kernel
 
 redef class Fail end
+
+var f = new Fail
+f.output
index 3022e6d..a0a2d27 100644 (file)
@@ -19,3 +19,6 @@ import module_simple
 redef class C
        redef var a: Int
 end
+
+var c = new C(new B)
+c.a.output
index 8267289..5a9a1e7 100644 (file)
@@ -19,3 +19,6 @@ import module_simple
 redef class C
        redef fun s do end
 end
+
+var c = new C(new B)
+c.s.output
index 4a9f644..e4f1b72 100644 (file)
@@ -19,3 +19,6 @@ import module_simple
 redef class C
        redef fun r(x: C) do end
 end
+
+var c = new C(new B)
+c.r
index 18f5452..02cd0f1 100644 (file)
@@ -19,3 +19,6 @@ import module_simple
 redef class C
        redef fun r(x: B): B do return self end
 end
+
+var c = new C(new B)
+c.r
index 1aedf5a..040de3e 100644 (file)
@@ -19,3 +19,6 @@ import module_simple
 redef class C
        redef fun s: Int do return 1 end
 end
+
+var c = new C(new B)
+c.s.output
index 3505137..9f737ac 100644 (file)
@@ -18,3 +18,5 @@ fun toto: Int
 do
        return
 end
+
+toto.output
index 41dc4b4..18f7808 100644 (file)
@@ -18,3 +18,5 @@ fun toto: Int
 do
        return '4'
 end
+
+(toto+1).output
index 188448b..7653555 100644 (file)
@@ -15,4 +15,5 @@
 # limitations under the License.
 
 if true or 6 then
+       1.output
 end
index 7da246a..47f3160 100644 (file)
@@ -27,3 +27,12 @@ class C
        super A
        redef fun foo: Int do return 3
 end
+
+var a = new A
+a.foo.output
+
+var b = new B
+b.foo
+
+var c = new C
+c.foo
index 5570921..00e43b6 100644 (file)
@@ -21,3 +21,6 @@ class B
        super A
        redef var a: Object = 2
 end
+
+var b = new B
+b.a.output
index 7a3ae87..669e139 100644 (file)
@@ -22,3 +22,6 @@ class B
        super A
 redef fun toto do end
 end
+
+var b = new B
+b.toto.output
index a3615ea..ac2b294 100644 (file)
@@ -23,3 +23,6 @@ class B
        super A
 redef fun toto(c: Object) do end
 end
+
+var b = new B
+b.toto(true)
index b0d63ac..35680b2 100644 (file)
@@ -23,3 +23,6 @@ class B
        super A
 redef fun toto(c: Char) do end
 end
+
+var b = new B
+b.toto(true)
index 0b23aef..17949f3 100644 (file)
@@ -20,5 +20,8 @@ end
 
 class B
        super A
-redef fun toto: Int do return 2end
+redef fun toto: Int do return 2 end
 end
+
+var b = new B
+b.toto.output
index 42c1848..e4330ff 100644 (file)
@@ -22,3 +22,6 @@ class B
        super A
 redef fun toto: Char do return 'a' end
 end
+
+var b = new B
+b.toto.output
index aeddbd9..605adfd 100644 (file)
@@ -21,3 +21,6 @@ class A
                super
        end
 end
+
+var a = new A
+a.foo
index cfe5302..10fd302 100644 (file)
@@ -21,3 +21,5 @@ class A
        super Fail
 end
 
+var a = new A
+a.output
index 4e49e03..b259d44 100644 (file)
@@ -21,3 +21,5 @@ class B
        super Array[Fail]
 end
 
+var b = new B
+b.output
index 7828cf6..77cab7c 100644 (file)
@@ -22,3 +22,8 @@ end
 
 class D[T: Array[Fail]]
 end
+
+var c = new C[Int]
+c.output
+var d = new D[Int]
+d.output
index 2862a61..d4f7b94 100644 (file)
@@ -33,3 +33,13 @@ class G
        fun md: Array[Fail] do return 0
 end
 
+var e = new E
+e.output
+var f = new F
+f.output
+var g = new G
+g.a.output
+g.ma(1)
+g.mb(1)
+g.mc(1).output
+g.md(1).output
index 8620254..4d9517f 100644 (file)
@@ -15,3 +15,4 @@
 # limitations under the License.
 
 var i = new Canard
+i.output