Merge: Snake phase names
authorJean Privat <jean@pryen.org>
Sat, 18 Apr 2015 09:47:34 +0000 (16:47 +0700)
committerJean Privat <jean@pryen.org>
Sat, 18 Apr 2015 09:47:34 +0000 (16:47 +0700)
Default name of phases where based on a lower cased version of their classnames.
That was bad. eg `FFILanguageAssignationPhase` -> `ffilanguageassignation`

So this PR snakecase them instead.

But the spec of `to_snake_case` was awful: `f_f_i_language_assignation`

So also fix the spec of this method and get something nice `ffi_language_assignation`.

Pull-Request: #1276
Reviewed-by: Alexis Laferrière <alexis.laf@xymus.net>
Reviewed-by: Romain Chanoir <chanoir.romain@courrier.uqam.ca>
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>

59 files changed:
lib/standard/collection/array.nit
lib/standard/string_search.nit
share/man/nitc.md
src/compiler/abstract_compiler.nit
src/interpreter/naive_interpreter.nit
src/metrics/detect_covariance.nit
src/modelize/modelize_property.nit
src/rapid_type_analysis.nit
src/semantize/typing.nit
src/toolcontext.nit
src/transform.nit
tests/base_autocast_array.nit [new file with mode: 0644]
tests/bench_421.nit
tests/bench_add_all.nit
tests/bench_complex_sort.nit
tests/bench_fib.nit
tests/bench_int_range_iterator.nit
tests/bench_netsim.nit
tests/bench_nsieve_bool.nit
tests/bench_send.nit
tests/bench_send2.nit
tests/bench_strfib.nit
tests/bench_string_append.nit
tests/bench_string_super.nit
tests/bench_string_tos.nit
tests/bench_tak.nit
tests/error_operators.nit [new file with mode: 0644]
tests/niti.skip
tests/nitvm.skip
tests/sav/base_autocast_array.res [new file with mode: 0644]
tests/sav/base_autocast_array_alt1.res [new file with mode: 0644]
tests/sav/base_autocast_array_alt2.res [new file with mode: 0644]
tests/sav/base_autocast_array_alt3.res [new file with mode: 0644]
tests/sav/bench_421.res
tests/sav/bench_add_all.res
tests/sav/bench_complex_sort.res [new file with mode: 0644]
tests/sav/bench_fib.res
tests/sav/bench_int_range_iterator.res
tests/sav/bench_netsim.res
tests/sav/bench_nsieve_bool.res
tests/sav/bench_send.res [new file with mode: 0644]
tests/sav/bench_send2.res [new file with mode: 0644]
tests/sav/bench_strfib.res
tests/sav/bench_string_append.res
tests/sav/bench_string_append_alt1.res
tests/sav/bench_string_super.res
tests/sav/bench_string_tos.res
tests/sav/error_operators.res [new file with mode: 0644]
tests/sav/nitg-e/base_autocast_array_alt2.res [new file with mode: 0644]
tests/sav/test_ffi_c_operators.res
tests/sav/test_hash.res
tests/sav/test_map.res
tests/sav/test_mem.res
tests/sav/test_new_native_alt1.res
tests/sav/test_toolcontext_args1.res
tests/sav/test_toolcontext_args2.res
tests/test_ffi_c_operators.nit
tests/test_map.nit
tests/test_mem.nit

index 3cc0b57..cdb5242 100644 (file)
@@ -147,6 +147,55 @@ abstract class AbstractArrayRead[E]
        private var free_iterator: nullable ArrayIterator[E] = null
 
        redef fun reverse_iterator do return new ArrayReverseIterator[E](self)
+
+       # Returns a sub-array containing `count` elements starting from `from`.
+       #
+       # For most cases (see other case bellow),
+       # the first element is `from` and
+       # the last element is `from+count-1`.
+       #
+       # ~~~
+       # var a = [10, 20, 30, 40, 50]
+       # assert a.sub(0, 3) == [10, 20, 30]
+       # assert a.sub(3, 2) == [40, 50]
+       # assert a.sub(3, 1) == [40]
+       # ~~~
+       #
+       # If `count` is 0 or negative then an empty array is returned
+       #
+       # ~~~
+       # assert a.sub(3,0).is_empty
+       # assert a.sub(3,-1).is_empty
+       # ~~~
+       #
+       # If `from < 0` or `from+count>length` then inexistent elements are ignored.
+       # In this case the length of the result is lower than count.
+       #
+       # ~~~
+       # assert a.sub(-2, 4)  == [10, 20]
+       # assert a.sub(4, 99)  == [50]
+       # assert a.sub(-9, 99) == [10,20,30,40,50]
+       # assert a.sub(-99, 9).is_empty
+       # ~~~
+       fun sub(from: Int, count: Int): Array[E] do
+               if from < 0 then
+                       count += from
+                       from = 0
+               end
+               if count < 0 then
+                       count = 0
+               end
+               var to = from + count
+               if to > length then
+                       to = length
+               end
+               var res = new Array[E].with_capacity(to - from)
+               while from < to do
+                       res.add(self[from])
+                       from += 1
+               end
+               return res
+       end
 end
 
 # Resizable one dimension array of objects.
index 3a885ad..437341f 100644 (file)
@@ -388,8 +388,14 @@ redef class Text
        fun split_once_on(p: Pattern): Array[SELFTYPE]
        do
                var m = p.search_in(self, 0)
-               if m == null then return [self]
-               return new Array[SELFTYPE].with_items(substring(0, m.from), substring_from(m.after))
+               var res = new Array[SELFTYPE]
+               if m == null then
+                       res.add self
+               else
+                       res.add substring(0, m.from)
+                       res.add substring_from(m.after)
+               end
+               return res
        end
 
        # Replace all occurences of a pattern with a string
index b2e664a..bc21fd3 100644 (file)
@@ -435,6 +435,11 @@ They are useless for a normal user.
 `--stub-man`
 :   Generate a stub manpage in pandoc markdown format.
 
+`--keep-going`
+:   Continue after errors, whatever the consequences.
+
+The tool does not stop after some errors but continue until it produces incorrect result, crashes, erases the hard drive, or just continue forever in an infinite loop.
+This option is used to test the robustness of the tools by allowing phases to progress on incorrect data.
 
 # ENVIRONMENT VARIABLES
 
index 2359c7d..1b8bf6a 100644 (file)
@@ -1146,40 +1146,43 @@ abstract class AbstractCompilerVisitor
        # Evaluate `args` as expressions in the call of `mpropdef` on `recv`.
        # This method is used to manage varargs in signatures and returns the real array
        # of runtime variables to use in the call.
-       fun varargize(mpropdef: MMethodDef, recv: RuntimeVariable, args: SequenceRead[AExpr]): Array[RuntimeVariable]
+       fun varargize(mpropdef: MMethodDef, map: nullable SignatureMap, recv: RuntimeVariable, args: SequenceRead[AExpr]): Array[RuntimeVariable]
        do
                var msignature = mpropdef.new_msignature or else mpropdef.msignature.as(not null)
                var res = new Array[RuntimeVariable]
                res.add(recv)
 
-               if args.is_empty then return res
+               if msignature.arity == 0 then return res
 
-               var vararg_rank = msignature.vararg_rank
-               var vararg_len = args.length - msignature.arity
-               if vararg_len < 0 then vararg_len = 0
+               if map == null then
+                       assert args.length == msignature.arity
+                       for ne in args do
+                               res.add self.expr(ne, null)
+                       end
+                       return res
+               end
+
+               # Eval in order of arguments, not parameters
+               var exprs = new Array[RuntimeVariable].with_capacity(args.length)
+               for ne in args do
+                       exprs.add self.expr(ne, null)
+               end
 
+               # Fill `res` with the result of the evaluation according to the mapping
                for i in [0..msignature.arity[ do
-                       if i == vararg_rank then
-                               var ne = args[i]
-                               if ne isa AVarargExpr then
-                                       var e = self.expr(ne.n_expr, null)
-                                       res.add(e)
-                                       continue
-                               end
-                               var vararg = new Array[RuntimeVariable]
-                               for j in [vararg_rank..vararg_rank+vararg_len] do
-                                       var e = self.expr(args[j], null)
-                                       vararg.add(e)
-                               end
-                               var elttype = msignature.mparameters[vararg_rank].mtype
+                       var param = msignature.mparameters[i]
+                       var j = map.map.get_or_null(i)
+                       if j == null then
+                               continue
+                       end
+                       if param.is_vararg and map.vararg_decl > 0 then
+                               var vararg = exprs.sub(j, map.vararg_decl)
+                               var elttype = param.mtype
                                var arg = self.vararg_instance(mpropdef, recv, vararg, elttype)
                                res.add(arg)
-                       else
-                               var j = i
-                               if i > vararg_rank then j += vararg_len
-                               var e = self.expr(args[j], null)
-                               res.add(e)
+                               continue
                        end
+                       res.add exprs[j]
                end
                return res
        end
@@ -2975,7 +2978,7 @@ redef class ASendExpr
        do
                var recv = v.expr(self.n_expr, null)
                var callsite = self.callsite.as(not null)
-               var args = v.varargize(callsite.mpropdef, recv, self.raw_arguments)
+               var args = v.varargize(callsite.mpropdef, callsite.signaturemap, recv, self.raw_arguments)
                return v.compile_callsite(callsite, args)
        end
 end
@@ -2985,7 +2988,7 @@ redef class ASendReassignFormExpr
        do
                var recv = v.expr(self.n_expr, null)
                var callsite = self.callsite.as(not null)
-               var args = v.varargize(callsite.mpropdef, recv, self.raw_arguments)
+               var args = v.varargize(callsite.mpropdef, callsite.signaturemap, recv, self.raw_arguments)
 
                var value = v.expr(self.n_value, null)
 
@@ -3007,26 +3010,33 @@ redef class ASuperExpr
 
                var callsite = self.callsite
                if callsite != null then
-                       var args = v.varargize(callsite.mpropdef, recv, self.n_args.n_exprs)
+                       var args
 
-                       # Add additional arguments for the super init call
-                       if args.length == 1 then
+                       if self.n_args.n_exprs.is_empty then
+                               # Add automatic arguments for the super init call
+                               args = [recv]
                                for i in [0..callsite.msignature.arity[ do
                                        args.add(v.frame.arguments[i+1])
                                end
+                       else
+                               args = v.varargize(callsite.mpropdef, callsite.signaturemap, recv, self.n_args.n_exprs)
                        end
+
                        # Super init call
                        var res = v.compile_callsite(callsite, args)
                        return res
                end
 
                var mpropdef = self.mpropdef.as(not null)
-               var args = v.varargize(mpropdef, recv, self.n_args.n_exprs)
-               if args.length == 1 then
+
+               var args
+               if self.n_args.n_exprs.is_empty then
                        args = v.frame.arguments
+               else
+                       args = v.varargize(mpropdef, signaturemap, recv, self.n_args.n_exprs)
                end
 
-               # stantard call-next-method
+               # Standard call-next-method
                return v.supercall(mpropdef, recv.mtype.as(MClassType), args)
        end
 end
@@ -3050,7 +3060,7 @@ redef class ANewExpr
                var callsite = self.callsite
                if callsite == null then return recv
 
-               var args = v.varargize(callsite.mpropdef, recv, self.n_args.n_exprs)
+               var args = v.varargize(callsite.mpropdef, callsite.signaturemap, recv, self.n_args.n_exprs)
                var res2 = v.compile_callsite(callsite, args)
                if res2 != null then
                        #self.debug("got {res2} from {mproperty}. drop {recv}")
@@ -3102,6 +3112,13 @@ redef class AIssetAttrExpr
        end
 end
 
+redef class AVarargExpr
+       redef fun expr(v)
+       do
+               return v.expr(self.n_expr, null)
+       end
+end
+
 redef class ADebugTypeExpr
        redef fun stmt(v)
        do
index 7d7cab9..c1bd59b 100644 (file)
@@ -370,42 +370,48 @@ class NaiveInterpreter
        # This method is used to manage varargs in signatures and returns the real array
        # of instances to use in the call.
        # Return `null` if one of the evaluation of the arguments return null.
-       fun varargize(mpropdef: MMethodDef, recv: Instance, args: SequenceRead[AExpr]): nullable Array[Instance]
+       fun varargize(mpropdef: MMethodDef, map: nullable SignatureMap, recv: Instance, args: SequenceRead[AExpr]): nullable Array[Instance]
        do
                var msignature = mpropdef.new_msignature or else mpropdef.msignature.as(not null)
                var res = new Array[Instance]
                res.add(recv)
 
-               if args.is_empty then return res
+               if msignature.arity == 0 then return res
+
+               if map == null then
+                       assert args.length == msignature.arity else debug("Expected {msignature.arity} args, got {args.length}")
+                       for ne in args do
+                               var e = self.expr(ne)
+                               if e == null then return null
+                               res.add e
+                       end
+                       return res
+               end
+
+               # Eval in order of arguments, not parameters
+               var exprs = new Array[Instance].with_capacity(args.length)
+               for ne in args do
+                       var e = self.expr(ne)
+                       if e == null then return null
+                       exprs.add e
+               end
 
-               var vararg_rank = msignature.vararg_rank
-               var vararg_len = args.length - msignature.arity
-               if vararg_len < 0 then vararg_len = 0
 
+               # Fill `res` with the result of the evaluation according to the mapping
                for i in [0..msignature.arity[ do
-                       if i == vararg_rank then
-                               var ne = args[i]
-                               if ne isa AVarargExpr then
-                                       var e = self.expr(ne.n_expr)
-                                       if e == null then return null
-                                       res.add(e)
-                                       continue
-                               end
-                               var vararg = new Array[Instance]
-                               for j in [vararg_rank..vararg_rank+vararg_len] do
-                                       var e = self.expr(args[j])
-                                       if e == null then return null
-                                       vararg.add(e)
-                               end
-                               var elttype = msignature.mparameters[vararg_rank].mtype.anchor_to(self.mainmodule, recv.mtype.as(MClassType))
-                               res.add(self.array_instance(vararg, elttype))
-                       else
-                               var j = i
-                               if i > vararg_rank then j += vararg_len
-                               var e = self.expr(args[j])
-                               if e == null then return null
-                               res.add(e)
+                       var param = msignature.mparameters[i]
+                       var j = map.map.get_or_null(i)
+                       if j == null then
+                               continue
+                       end
+                       if param.is_vararg and map.vararg_decl > 0 then
+                               var vararg = exprs.sub(j, map.vararg_decl)
+                               var elttype = param.mtype.anchor_to(self.mainmodule, recv.mtype.as(MClassType))
+                               var arg = self.array_instance(vararg, elttype)
+                               res.add(arg)
+                               continue
                        end
+                       res.add exprs[j]
                end
                return res
        end
@@ -1740,7 +1746,7 @@ redef class ASendExpr
        do
                var recv = v.expr(self.n_expr)
                if recv == null then return null
-               var args = v.varargize(callsite.mpropdef, recv, self.raw_arguments)
+               var args = v.varargize(callsite.mpropdef, callsite.signaturemap, recv, self.raw_arguments)
                if args == null then return null
 
                var res = v.callsite(callsite, args)
@@ -1753,7 +1759,7 @@ redef class ASendReassignFormExpr
        do
                var recv = v.expr(self.n_expr)
                if recv == null then return
-               var args = v.varargize(callsite.mpropdef, recv, self.raw_arguments)
+               var args = v.varargize(callsite.mpropdef, callsite.signaturemap, recv, self.raw_arguments)
                if args == null then return
                var value = v.expr(self.n_value)
                if value == null then return
@@ -1777,29 +1783,35 @@ redef class ASuperExpr
 
                var callsite = self.callsite
                if callsite != null then
-                       var args = v.varargize(callsite.mpropdef, recv, self.n_args.n_exprs)
-                       if args == null then return null
-                       # Add additional arguments for the super init call
-                       if args.length == 1 then
+                       var args
+                       if self.n_args.n_exprs.is_empty then
+                               # Add automatic arguments for the super init call
+                               args = [recv]
                                for i in [0..callsite.msignature.arity[ do
                                        args.add(v.frame.arguments[i+1])
                                end
+                       else
+                               args = v.varargize(callsite.mpropdef, callsite.signaturemap, recv, self.n_args.n_exprs)
+                               if args == null then return null
                        end
+
                        # Super init call
                        var res = v.callsite(callsite, args)
                        return res
                end
 
-               # standard call-next-method
+               # Standard call-next-method
                var mpropdef = self.mpropdef
                mpropdef = mpropdef.lookup_next_definition(v.mainmodule, recv.mtype)
 
-               var args = v.varargize(mpropdef, recv, self.n_args.n_exprs)
-               if args == null then return null
-
-               if args.length == 1 then
+               var args
+               if self.n_args.n_exprs.is_empty then
                        args = v.frame.arguments
+               else
+                       args = v.varargize(mpropdef, signaturemap, recv, self.n_args.n_exprs)
+                       if args == null then return null
                end
+
                var res = v.call(mpropdef, args)
                return res
        end
@@ -1814,7 +1826,7 @@ redef class ANewExpr
                var callsite = self.callsite
                if callsite == null then return recv
 
-               var args = v.varargize(callsite.mpropdef, recv, self.n_args.n_exprs)
+               var args = v.varargize(callsite.mpropdef, callsite.signaturemap, recv, self.n_args.n_exprs)
                if args == null then return null
                var res2 = v.callsite(callsite, args)
                if res2 != null then
@@ -1876,6 +1888,13 @@ redef class AIssetAttrExpr
        end
 end
 
+redef class AVarargExpr
+       redef fun expr(v)
+       do
+               return v.expr(self.n_expr)
+       end
+end
+
 redef class ADebugTypeExpr
        redef fun stmt(v)
        do
index 4a3437d..1ab719b 100644 (file)
@@ -343,7 +343,7 @@ redef class TypeVisitor
                return sub
        end
 
-       redef fun check_subtype(node: ANode, sub, sup: MType): nullable MType
+       redef fun check_subtype(node: ANode, sub, sup: MType, autocast: Bool): nullable MType
        do
                var res = super
 
@@ -361,6 +361,9 @@ redef class TypeVisitor
                        if node isa AAsCastExpr then
                                return res
                        end
+                       if not autocast then
+                               return res
+                       end
                        sup = supx.resolve_for(anchor.mclass.mclass_type, anchor, mmodule, true)
                        if self.is_subtype(sub, sup) then
                                dcp.cpt_autocast.inc("vt")
index 9cc9580..c0d3890 100644 (file)
@@ -790,11 +790,17 @@ redef class AMethPropdef
                        name = amethodid.collect_text
                        name_node = amethodid
 
-                       if name == "+" and self.n_signature.n_params.length == 0 then
+                       var arity = self.n_signature.n_params.length
+                       if name == "+" and arity == 0 then
                                name = "unary +"
-                       end
-                       if name == "-" and self.n_signature.n_params.length == 0 then
+                       else if name == "-" and arity == 0 then
                                name = "unary -"
+                       else
+                               if amethodid.is_binary and arity != 1 then
+                                       modelbuilder.error(self.n_signature, "Syntax Error: binary operator `{name}` requires exactly one parameter; got {arity}.")
+                               else if amethodid.min_arity > arity then
+                                       modelbuilder.error(self.n_signature, "Syntax Error: `{name}` requires at least {amethodid.min_arity} parameter(s); got {arity}.")
+                               end
                        end
                end
 
@@ -868,6 +874,9 @@ redef class AMethPropdef
                        end
                end
 
+               var accept_special_last_parameter = self.n_methid == null or self.n_methid.accept_special_last_parameter
+               var return_is_mandatory = self.n_methid != null and self.n_methid.return_is_mandatory
+
                # Retrieve info from the signature AST
                var param_names = new Array[String] # Names of parameters from the AST
                var param_types = new Array[MType] # Types of parameters from the AST
@@ -941,6 +950,14 @@ redef class AMethPropdef
                # In `new`-factories, the return type is by default the classtype.
                if ret_type == null and mpropdef.mproperty.is_new then ret_type = mclassdef.mclass.mclass_type
 
+               # Special checks for operator methods
+               if not accept_special_last_parameter and mparameters.not_empty and mparameters.last.is_vararg then
+                       modelbuilder.error(self.n_signature.n_params.last, "Error: illegal variadic parameter `{mparameters.last}` for `{mpropdef.mproperty.name}`.")
+               end
+               if ret_type == null and return_is_mandatory then
+                       modelbuilder.error(self.n_methid, "Error: mandatory return type for `{mpropdef.mproperty.name}`.")
+               end
+
                msignature = new MSignature(mparameters, ret_type)
                mpropdef.msignature = msignature
                mpropdef.is_abstract = self.get_single_annotation("abstract", modelbuilder) != null
@@ -1022,6 +1039,56 @@ redef class AMethPropdef
        end
 end
 
+redef class AMethid
+       # Is a return required?
+       #
+       # * True for operators and brackets.
+       # * False for id and assignment.
+       fun return_is_mandatory: Bool do return true
+
+       # Can the last parameter be special like a vararg?
+       #
+       # * False for operators: the last one is in fact the only one.
+       # * False for assignments: it is the right part of the assignment.
+       # * True for ids and brackets.
+       fun accept_special_last_parameter: Bool do return false
+
+       # The minimum required number of parameters.
+       #
+       # * 1 for binary operators
+       # * 1 for brackets
+       # * 1 for assignments
+       # * 2 for bracket assignments
+       # * 0 for ids
+       fun min_arity: Int do return 1
+
+       # Is the `self` a binary operator?
+       fun is_binary: Bool do return true
+end
+
+redef class AIdMethid
+       redef fun return_is_mandatory do return false
+       redef fun accept_special_last_parameter do return true
+       redef fun min_arity do return 0
+       redef fun is_binary do return false
+end
+
+redef class ABraMethid
+       redef fun accept_special_last_parameter do return true
+       redef fun is_binary do return false
+end
+
+redef class ABraassignMethid
+       redef fun return_is_mandatory do return false
+       redef fun min_arity do return 2
+       redef fun is_binary do return false
+end
+
+redef class AAssignMethid
+       redef fun return_is_mandatory do return false
+       redef fun is_binary do return false
+end
+
 redef class AAttrPropdef
        redef type MPROPDEF: MAttributeDef
 
index 3f81bf8..81e14fa 100644 (file)
@@ -540,6 +540,8 @@ redef class AArrayExpr
                mtype = v.cleanup_type(mtype).as(not null)
                var prop = v.get_method(mtype, "with_native")
                v.add_monomorphic_send(mtype, prop)
+               v.add_callsite(with_capacity_callsite)
+               v.add_callsite(push_callsite)
        end
 end
 
index 7ef06e0..97e200c 100644 (file)
@@ -105,13 +105,13 @@ private class TypeVisitor
        # If `sub` is a safe subtype of `sup` then return `sub`.
        # If `sub` is an unsafe subtype (ie an implicit cast is required), then return `sup`.
        #
-       # The point of the return type is to determinate the usable type on an expression:
+       # The point of the return type is to determinate the usable type on an expression when `autocast` is true:
        # If the suptype is safe, then the return type is the one on the expression typed by `sub`.
        # Is the subtype is unsafe, then the return type is the one of an implicit cast on `sup`.
-       fun check_subtype(node: ANode, sub, sup: MType): nullable MType
+       fun check_subtype(node: ANode, sub, sup: MType, autocast: Bool): nullable MType
        do
                if self.is_subtype(sub, sup) then return sub
-               if self.is_subtype(sub, self.anchor_to(sup)) then
+               if autocast and self.is_subtype(sub, self.anchor_to(sup)) then
                        # FIXME workaround to the current unsafe typing policy. To remove once fixed virtual types exists.
                        #node.debug("Unsafe typing: expected {sup}, got {sub}")
                        return sup
@@ -166,7 +166,7 @@ private class TypeVisitor
 
                if sup == null then return null # Forward error
 
-               var res = check_subtype(nexpr, sub, sup)
+               var res = check_subtype(nexpr, sub, sup, true)
                if res != sub then
                        nexpr.implicit_cast_to = res
                end
@@ -398,47 +398,58 @@ private class TypeVisitor
        # Visit the expressions of args and check their conformity with the corresponding type in signature
        # The point of this method is to handle varargs correctly
        # Note: The signature must be correctly adapted
-       fun check_signature(node: ANode, args: Array[AExpr], mproperty: MProperty, msignature: MSignature): Bool
+       fun check_signature(node: ANode, args: Array[AExpr], mproperty: MProperty, msignature: MSignature): nullable SignatureMap
        do
                var vararg_rank = msignature.vararg_rank
                if vararg_rank >= 0 then
                        if args.length < msignature.arity then
                                modelbuilder.error(node, "Error: expected at least {msignature.arity} argument(s) for `{mproperty}{msignature}`; got {args.length}. See introduction at `{mproperty.full_name}`.")
-                               return false
+                               return null
                        end
                else if args.length != msignature.arity then
                        modelbuilder.error(node, "Error: expected {msignature.arity} argument(s) for `{mproperty}{msignature}`; got {args.length}. See introduction at `{mproperty.full_name}`.")
-                       return false
+                       return null
                end
 
                #debug("CALL {unsafe_type}.{msignature}")
 
+               # Associate each parameter to a position in the arguments
+               var map = new SignatureMap
+
                var vararg_decl = args.length - msignature.arity
+               var j = 0
                for i in [0..msignature.arity[ do
-                       var j = i
-                       if i == vararg_rank then continue # skip the vararg
-                       if i > vararg_rank then
-                               j = i + vararg_decl
+                       var param = msignature.mparameters[i]
+                       var arg = args[j]
+                       map.map[i] = j
+                       j += 1
+
+                       if i == vararg_rank then
+                               j += vararg_decl
+                               continue # skip the vararg
                        end
-                       var paramtype = msignature.mparameters[i].mtype
-                       self.visit_expr_subtype(args[j], paramtype)
+
+                       var paramtype = param.mtype
+                       self.visit_expr_subtype(arg, paramtype)
                end
                if vararg_rank >= 0 then
                        var paramtype = msignature.mparameters[vararg_rank].mtype
                        var first = args[vararg_rank]
                        if vararg_decl == 0 and first isa AVarargExpr then
                                var mclass = get_mclass(node, "Array")
-                               if mclass == null then return false # Forward error
+                               if mclass == null then return null # Forward error
                                var array_mtype = mclass.get_mtype([paramtype])
                                self.visit_expr_subtype(first.n_expr, array_mtype)
                                first.mtype  = first.n_expr.mtype
                        else
-                               for j in [vararg_rank..vararg_rank+vararg_decl] do
-                                       self.visit_expr_subtype(args[j], paramtype)
+                               map.vararg_decl = vararg_decl + 1
+                               for i in [vararg_rank..vararg_rank+vararg_decl] do
+                                       self.visit_expr_subtype(args[i], paramtype)
                                end
                        end
                end
-               return true
+
+               return map
        end
 
        fun error(node: ANode, message: String)
@@ -508,6 +519,20 @@ private class TypeVisitor
        end
 end
 
+# Mapping between parameters and arguments in a call.
+#
+# Parameters and arguments are not stored in the class but referenced by their position (starting from 0)
+#
+# The point of this class is to help engine and other things to map arguments in the AST to parameters of the model.
+class SignatureMap
+       # Associate a parameter to an argument
+       var map = new ArrayMap[Int, Int]
+
+       # The length of the vararg sequence
+       # 0 if no vararg or if reverse vararg (cf `AVarargExpr`)
+       var vararg_decl: Int = 0
+end
+
 # A specific method call site with its associated informations.
 class CallSite
        # The associated node for location
@@ -540,9 +565,15 @@ class CallSite
        # Is a implicit cast required on erasure typing policy?
        var erasure_cast: Bool
 
+       # The mapping used on the call to associate arguments to parameters
+       # If null then no specific association is required.
+       var signaturemap: nullable SignatureMap = null
+
        private fun check_signature(v: TypeVisitor, args: Array[AExpr]): Bool
        do
-               return v.check_signature(self.node, args, self.mproperty, self.msignature)
+               var map = v.check_signature(self.node, args, self.mproperty, self.msignature)
+               signaturemap = map
+               return map == null
        end
 end
 
@@ -837,7 +868,7 @@ redef class AReassignFormExpr
                var value_type = v.visit_expr_subtype(self.n_value, msignature.mparameters.first.mtype)
                if value_type == null then return null # Skip error
 
-               v.check_subtype(self, rettype, writetype)
+               v.check_subtype(self, rettype, writetype, false)
                return rettype
        end
 end
@@ -1329,7 +1360,7 @@ redef class AArrayExpr
                        end
                        set_comprehension(e)
                        if mtype != null then
-                               if v.check_subtype(e, t, mtype) == null then return # Skip error
+                               if v.check_subtype(e, t, mtype, false) == null then return # Forward error
                                if t == mtype then useless = true
                        else
                                mtypes.add(t)
@@ -1737,7 +1768,7 @@ redef class ASuperExpr
                msignature = v.resolve_for(msignature, recvtype, true).as(MSignature)
                var args = self.n_args.to_a
                if args.length > 0 then
-                       v.check_signature(self, args, mproperty, msignature)
+                       signaturemap = v.check_signature(self, args, mproperty, msignature)
                end
                self.mtype = msignature.return_mtype
                self.is_typed = true
@@ -1745,6 +1776,10 @@ redef class ASuperExpr
                mpropdef = v.mpropdef.as(MMethodDef)
        end
 
+       # The mapping used on the call to associate arguments to parameters.
+       # If null then no specific association is required.
+       var signaturemap: nullable SignatureMap
+
        private fun process_superinit(v: TypeVisitor)
        do
                var anchor = v.anchor
index 645038e..8196aeb 100644 (file)
@@ -365,6 +365,9 @@ class ToolContext
        # Option --stop-on-first-error
        var opt_stop_on_first_error = new OptionBool("Stop on first error", "--stop-on-first-error")
 
+       # Option --keep-going
+       var opt_keep_going = new OptionBool("Continue after errors, whatever the consequences", "--keep-going")
+
        # Option --no-color
        var opt_no_color = new OptionBool("Do not use color to display errors and warnings", "--no-color")
 
@@ -379,7 +382,7 @@ class ToolContext
 
        init
        do
-               option_context.add_option(opt_warn, opt_warning, opt_quiet, opt_stop_on_first_error, opt_no_color, opt_log, opt_log_dir, opt_nit_dir, opt_help, opt_version, opt_set_dummy_tool, opt_verbose, opt_bash_completion, opt_stub_man)
+               option_context.add_option(opt_warn, opt_warning, opt_quiet, opt_stop_on_first_error, opt_keep_going, opt_no_color, opt_log, opt_log_dir, opt_nit_dir, opt_help, opt_version, opt_set_dummy_tool, opt_verbose, opt_bash_completion, opt_stub_man)
 
                # Hide some internal options
                opt_stub_man.hidden = true
@@ -485,6 +488,8 @@ The Nit language documentation and the source code of its tools and libraries ma
                # Set verbose level
                verbose_level = opt_verbose.value
 
+               if opt_keep_going.value then keep_going = true
+
                if self.opt_quiet.value then self.opt_warn.value = 0
 
                if opt_log_dir.value != null then log_directory = opt_log_dir.value.as(not null)
index 118142a..4fa28c0 100644 (file)
@@ -20,6 +20,7 @@ import astbuilder
 import astvalidation
 import semantize
 intrude import semantize::scope
+intrude import semantize::typing
 
 redef class ToolContext
        var transform_phase: Phase = new TransformPhase(self, [typing_phase, auto_super_init_phase])
@@ -105,6 +106,14 @@ redef class AExpr
                end
                super
        end
+
+       redef fun replace_with(other)
+       do
+               super
+               if other isa AExpr then
+                       if other.implicit_cast_to == null then other.implicit_cast_to = implicit_cast_to
+               end
+       end
 end
 
 redef class AVardeclExpr
diff --git a/tests/base_autocast_array.nit b/tests/base_autocast_array.nit
new file mode 100644 (file)
index 0000000..9beb291
--- /dev/null
@@ -0,0 +1,45 @@
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import standard::collection::array
+
+class A
+       type V: nullable Object
+       var v: V
+
+       fun test_array: Array[V]
+       do
+               #alt3#v = 10
+               return [v] #alt1-2#
+               #alt1#return [10:V]
+               #alt2#return [10]
+       end
+end
+
+class B
+       super A
+       redef type V: Bool
+end
+
+var a = new A(1)
+
+a.test_array.first.output
+
+var ab = new A(true)
+
+ab.test_array.first.output
+
+var b = new B(true)
+
+b.test_array.first.output
index b87347c..a868768 100644 (file)
@@ -29,7 +29,7 @@ do
        return steps
 end
 
-var n = 10
+var n = 456
 if not args.is_empty then
        n = args.first.to_i
 end
index 733ac9b..0c9bc5e 100644 (file)
 
 # Performance test for Array::add_all
 
-import standard::collection
+var n = 10
+if args.not_empty then n = args.first.to_i
+
+var nn = 1.lshift(n)
 
 var a = new Array[Numeric]
 var b = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
-for i in 10000.times do
+for i in nn.times do
        a.add_all b
 end
 
 var c = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0]
-for i in 10000.times do
+for i in nn.times do
        a.add_all c
 end
 
index 2eef2cb..5d96859 100644 (file)
@@ -26,6 +26,7 @@ class A
        redef fun val1: Int do return _a
 
        init(i: Int) do _a = i
+       redef fun to_s do return "Aa{a}"
 end
 
 class Elt2
@@ -39,6 +40,7 @@ end
 class B
        super Elt2
        init(i: Int) do initelt2(i)
+       redef fun to_s do return "Bb{b}"
 end
 
 class C
@@ -52,6 +54,7 @@ class C
                _c = i
                _d = j
        end
+       redef fun to_s do return "Cc{c}d{d}"
 end
 
 class D
@@ -64,6 +67,7 @@ class D
                init(i)
                initelt2(j)
        end
+       redef fun to_s do return "Da{a}b{b}"
 end
 
 class E
@@ -71,6 +75,7 @@ class E
        redef fun val1: Int do return 5 end
 
        init(i: Int) do initelt2(i)
+       redef fun to_s do return "Eb{b}"
 end
 
 class EltComparator
@@ -111,7 +116,8 @@ do
        end
 end
 
-var n = 100
+srand_from(0)
+var n = 20
 
 if not args.is_empty then
        n = args.first.to_i
@@ -122,9 +128,12 @@ for i in [0..n[ do
        array.push(generator)
 end
 
+print array.join(", ")
+
 var comparator = new EltComparator
 for i in [0..n[ do
        comparator.sort(array)
        comparator.toggle
 end
 
+print array.join(", ")
index 69dc371..8c7d4da 100644 (file)
@@ -30,7 +30,7 @@ redef class Int
        end
 end
 
-var n = 10
+var n = 20
 if not args.is_empty then
        n = args.first.to_i
 end
index 17f24d2..3d906f0 100644 (file)
@@ -14,7 +14,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-var nb = 5
+var nb = 25
 if not args.is_empty then nb = args.first.to_i
 
 var cpt = 0
index f784635..0e13e59 100644 (file)
@@ -267,11 +267,11 @@ e1.attach(a1)
 b1.start
 b2.start
 
-var nb = 100000
+var nb = 10
 if not args.is_empty then
        nb = args.first.to_i
 end
 
-s.run_for(nb)
+s.run_for(1.lshift(nb))
 print(c1.count)
 
index 36da71a..634e3cb 100644 (file)
@@ -38,11 +38,11 @@ end
 
 fun test(n: Int)
 do
-       var m = 10000.lshift(n)
+       var m = 1000.lshift(n)
        print("Primes up to {m} {nsieve(m)}")
 end
 
-var n = 2
+var n = 3
 if args.length == 1 then
        n = args.first.to_i
 end
index 03218dc..d3c1b7c 100644 (file)
@@ -44,8 +44,11 @@ class A
        end
        fun baz
        do
+               i += 1
        end
 
+       var i = 0
+
        init
        do
        end
@@ -97,7 +100,16 @@ b.val = 1
 c.val = 2
 d.val = 3
 var i = 0
-while i < 100000 do
+
+var n = 10
+if args.not_empty then n = args.first.to_i
+
+while i < 1.lshift(n) do
        a.hop(b, c, d)
        i = i + 1
 end
+
+print a.i
+print b.i
+print c.i
+print d.i
index e296465..a4f53ad 100644 (file)
@@ -18,8 +18,9 @@ redef class Object
        fun foo do end
 end
 class A
-       redef fun foo do end
+       redef fun foo do i += 1 end
        init do end
+       var i = 0
 end
 class B
        super A
@@ -53,6 +54,9 @@ class F
 
 end
 
+var n = 10
+if args.not_empty then n = args.first.to_i
+
 var nb = 60
 var a = new Array[Object].with_capacity(nb)
 for i in [0..(nb/6)[ do
@@ -63,9 +67,12 @@ for i in [0..(nb/6)[ do
        a[i*6+4] = new E
        a[i*6+5] = new F
 end
-for i in [0..1000000[ do
+for i in [0..1.lshift(n)[ do
        for j in [0..nb[ do
                a[j].foo
        end
 end
 
+for j in [0..nb[ do
+       print a[j].as(A).i
+end
index 2357686..f65d436 100644 (file)
@@ -32,7 +32,7 @@ if args.has("-q") then
        args.remove("-q")
 end
 
-var n = 5
+var n = 15
 if args.length > 0 then n = args.first.to_i
 var res = strfib(n)
 
index c99dc83..df00536 100644 (file)
@@ -17,7 +17,7 @@
 #alt1 import standard
 #alt1 import standard::ropes
 
-var n = 7
+var n = 4
 if not args.is_empty then
        n = args.first.to_i
 end
index ad27304..c78f448 100644 (file)
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+var n = 10
+if args.not_empty then n = args.first.to_i
+
 var s = "*"
-var i = 0
-while i < 8 do
+var i = 1
+while i < n do
        s = "Je dis Â«{s}» et redis Â«{s}» et trois fois de plus : Â«{s}{s}{s}».\n"
        i = i + 1
 end
index 1d59691..dbc8ac9 100644 (file)
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+var n = 10
+if args.not_empty then n = args.first.to_i
+
 var s = "*"
 var i = 0
-while i < 8 do
+while i < n do
        s = ["Je dis Â«", s, "» et redis Â«", s, "» et trois fois de plus : Â«", s, s, s, "».\n"].to_s
        i = i + 1
 end
index d5be5e8..ac128d3 100644 (file)
@@ -27,4 +27,7 @@ do
        end
 end
 
-print(tak(37,12,6))
+var n = 17
+if args.not_empty then n = args.first.to_i
+
+print(tak(n,12,6))
diff --git a/tests/error_operators.nit b/tests/error_operators.nit
new file mode 100644 (file)
index 0000000..db94029
--- /dev/null
@@ -0,0 +1,91 @@
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# no return
+class A
+       fun + do abort
+       fun +(a: A) do abort
+       fun - do abort
+       fun -(a: A) do abort
+       fun *(a: A) do abort
+       fun /(a: A) do abort
+       fun %(a: A) do abort
+       fun <(a: A) do abort
+       fun >(a: A) do abort
+       fun <=(a: A) do abort
+       fun >=(a: A) do abort
+       fun <=>(a: A) do abort
+       fun <<(a: A) do abort
+       fun >>(a: A) do abort
+       fun foo=(a: A) do abort # should be fine
+       fun [](a: A) do abort
+       fun []=(a, b: A) do abort # should be fine
+end
+
+# not enough parameters
+class B
+       fun +: A do abort # should be fine
+       fun -: A do abort # should be fine
+       fun *: A do abort
+       fun /: A do abort
+       fun %: A do abort
+       fun <: A do abort
+       fun >: A do abort
+       fun <=: A do abort
+       fun >=: A do abort
+       fun <=>: A do abort
+       fun <<: A do abort
+       fun >>: A do abort
+       fun foo= do abort
+       fun []: A do abort
+       fun []=(a: A) do abort
+end
+
+# too much parameters
+class C
+       fun +(a,b,c:A): A do abort
+       fun -(a,b,c:A): A do abort
+       fun *(a,b,c:A): A do abort
+       fun /(a,b,c:A): A do abort
+       fun %(a,b,c:A): A do abort
+       fun <(a,b,c:A): A do abort
+       fun >(a,b,c:A): A do abort
+       fun <=(a,b,c:A): A do abort
+       fun >=(a,b,c:A): A do abort
+       fun <=>(a,b,c:A): A do abort
+       fun <<(a,b,c:A): A do abort
+       fun >>(a,b,c:A): A do abort
+       fun foo=(a,b,c:A) do abort # should be fine
+       fun [](a,b,c:A): A do abort # should be fine
+       fun []=(a,b,c:A) do abort # should be fine
+end
+
+# bad vararg
+class D
+       fun +(a:A...): A do abort
+       fun -(a:A...): A do abort
+       fun *(a:A...): A do abort
+       fun /(a:A...): A do abort
+       fun %(a:A...): A do abort
+       fun <(a:A...): A do abort
+       fun >(a:A...): A do abort
+       fun <=(a:A...): A do abort
+       fun >=(a:A...): A do abort
+       fun <=>(a:A...): A do abort
+       fun <<(a:A...): A do abort
+       fun >>(a:A...): A do abort
+       fun foo=(a,b,c:A, d:A...) do abort
+       fun [](a,b,c:A, d:A...): A do abort # should be fine
+       fun []=(a,b,c:A, d:A...) do abort
+end
index a78f621..61b016a 100644 (file)
@@ -1,6 +1,4 @@
-test_mem
 shoot_logic
-bench_
 nit_args1
 nit_args3
 nit_args4
@@ -20,6 +18,5 @@ nitunit_args
 nitpretty_args
 hamming_number
 hailstone
-test_map
-nitls
-nituml
+nitls_args
+nituml_args
index a78f621..61b016a 100644 (file)
@@ -1,6 +1,4 @@
-test_mem
 shoot_logic
-bench_
 nit_args1
 nit_args3
 nit_args4
@@ -20,6 +18,5 @@ nitunit_args
 nitpretty_args
 hamming_number
 hailstone
-test_map
-nitls
-nituml
+nitls_args
+nituml_args
diff --git a/tests/sav/base_autocast_array.res b/tests/sav/base_autocast_array.res
new file mode 100644 (file)
index 0000000..9acd049
--- /dev/null
@@ -0,0 +1,3 @@
+1
+true
+true
diff --git a/tests/sav/base_autocast_array_alt1.res b/tests/sav/base_autocast_array_alt1.res
new file mode 100644 (file)
index 0000000..0c8e503
--- /dev/null
@@ -0,0 +1 @@
+alt/base_autocast_array_alt1.nit:25,11--12: Type Error: expected `V`, got `Int`.
diff --git a/tests/sav/base_autocast_array_alt2.res b/tests/sav/base_autocast_array_alt2.res
new file mode 100644 (file)
index 0000000..f8e020c
--- /dev/null
@@ -0,0 +1,3 @@
+Runtime error: Cast failed. Expected `Array[V]`, got `Array[Int]` (alt/base_autocast_array_alt2.nit:26)
+10
+10
diff --git a/tests/sav/base_autocast_array_alt3.res b/tests/sav/base_autocast_array_alt3.res
new file mode 100644 (file)
index 0000000..a93fcc4
--- /dev/null
@@ -0,0 +1,3 @@
+Runtime error: Cast failed. Expected `V`, got `Int` (alt/base_autocast_array_alt3.nit:23)
+10
+10
index 5079bf7..4e2232f 100644 (file)
@@ -1 +1 @@
-9: 19
+327: 143
diff --git a/tests/sav/bench_complex_sort.res b/tests/sav/bench_complex_sort.res
new file mode 100644 (file)
index 0000000..3f09c96
--- /dev/null
@@ -0,0 +1,2 @@
+Eb3, Da7b9, Aa3, Da2b5, Cc6d3, Cc9d9, Da7b1, Da0b2, Aa8, Aa4, Aa1, Eb2, Cc8d6, Bb6, Cc4d9, Bb7, Cc7d4, Eb2, Bb8, Eb0
+Da0b2, Aa1, Da2b5, Bb6, Aa3, Bb7, Bb8, Aa4, Cc4d9, Eb3, Eb2, Eb2, Eb0, Cc6d3, Cc7d4, Da7b1, Da7b9, Cc8d6, Aa8, Cc9d9
index d9e91fa..134debf 100644 (file)
@@ -1,3 +1,3 @@
-Primes up to 40000 4203
-Primes up to 20000 2262
-Primes up to 10000 1229
+Primes up to 8000 1007
+Primes up to 4000 550
+Primes up to 2000 303
diff --git a/tests/sav/bench_send.res b/tests/sav/bench_send.res
new file mode 100644 (file)
index 0000000..cb4ed12
--- /dev/null
@@ -0,0 +1,4 @@
+8192
+14336
+22528
+33792
diff --git a/tests/sav/bench_send2.res b/tests/sav/bench_send2.res
new file mode 100644 (file)
index 0000000..44053db
--- /dev/null
@@ -0,0 +1,60 @@
+1024
+0
+1024
+0
+0
+0
+1024
+0
+1024
+0
+0
+0
+1024
+0
+1024
+0
+0
+0
+1024
+0
+1024
+0
+0
+0
+1024
+0
+1024
+0
+0
+0
+1024
+0
+1024
+0
+0
+0
+1024
+0
+1024
+0
+0
+0
+1024
+0
+1024
+0
+0
+0
+1024
+0
+1024
+0
+0
+0
+1024
+0
+1024
+0
+0
+0
index 4e58388..aa267d1 100644 (file)
@@ -1 +1 @@
-((()(()))((())(()(()))))
+(((((((()(()))((())(()(()))))(((())(()(())))((()(()))((())(()(()))))))((((())(()(())))((()(()))((())(()(())))))(((()(()))((())(()(()))))(((())(()(())))((()(()))((())(()(()))))))))(((((())(()(())))((()(()))((())(()(())))))(((()(()))((())(()(()))))(((())(()(())))((()(()))((())(()(())))))))((((()(()))((())(()(()))))(((())(()(())))((()(()))((())(()(()))))))((((())(()(())))((()(()))((())(()(())))))(((()(()))((())(()(()))))(((())(()(())))((()(()))((())(()(()))))))))))((((((())(()(())))((()(()))((())(()(())))))(((()(()))((())(()(()))))(((())(()(())))((()(()))((())(()(())))))))((((()(()))((())(()(()))))(((())(()(())))((()(()))((())(()(()))))))((((())(()(())))((()(()))((())(()(())))))(((()(()))((())(()(()))))(((())(()(())))((()(()))((())(()(())))))))))(((((()(()))((())(()(()))))(((())(()(())))((()(()))((())(()(()))))))((((())(()(())))((()(()))((())(()(())))))(((()(()))((())(()(()))))(((())(()(())))((()(()))((())(()(()))))))))(((((())(()(())))((()(()))((())(()(())))))(((()(()))((())(()(()))))(((())(()(())))((()(()))((())(()(())))))))((((()(()))((())(()(()))))(((())(()(())))((()(()))((())(()(()))))))((((())(()(())))((()(()))((())(()(())))))(((()(()))((())(()(()))))(((())(()(())))((()(()))((())(()(()))))))))))))(((((((())(()(())))((()(()))((())(()(())))))(((()(()))((())(()(()))))(((())(()(())))((()(()))((())(()(())))))))((((()(()))((())(()(()))))(((())(()(())))((()(()))((())(()(()))))))((((())(()(())))((()(()))((())(()(())))))(((()(()))((())(()(()))))(((())(()(())))((()(()))((())(()(())))))))))(((((()(()))((())(()(()))))(((())(()(())))((()(()))((())(()(()))))))((((())(()(())))((()(()))((())(()(())))))(((()(()))((())(()(()))))(((())(()(())))((()(()))((())(()(()))))))))(((((())(()(())))((()(()))((())(()(())))))(((()(()))((())(()(()))))(((())(()(())))((()(()))((())(()(())))))))((((()(()))((())(()(()))))(((())(()(())))((()(()))((())(()(()))))))((((())(()(())))((()(()))((())(()(())))))(((()(()))((())(()(()))))(((())(()(())))((()(()))((())(()(())))))))))))((((((()(()))((())(()(()))))(((())(()(())))((()(()))((())(()(()))))))((((())(()(())))((()(()))((())(()(())))))(((()(()))((())(()(()))))(((())(()(())))((()(()))((())(()(()))))))))(((((())(()(())))((()(()))((())(()(())))))(((()(()))((())(()(()))))(((())(()(())))((()(()))((())(()(())))))))((((()(()))((())(()(()))))(((())(()(())))((()(()))((())(()(()))))))((((())(()(())))((()(()))((())(()(())))))(((()(()))((())(()(()))))(((())(()(())))((()(()))((())(()(()))))))))))((((((())(()(())))((()(()))((())(()(())))))(((()(()))((())(()(()))))(((())(()(())))((()(()))((())(()(())))))))((((()(()))((())(()(()))))(((())(()(())))((()(()))((())(()(()))))))((((())(()(())))((()(()))((())(()(())))))(((()(()))((())(()(()))))(((())(()(())))((()(()))((())(()(())))))))))(((((()(()))((())(()(()))))(((())(()(())))((()(()))((())(()(()))))))((((())(()(())))((()(()))((())(()(())))))(((()(()))((())(()(()))))(((())(()(())))((()(()))((())(()(()))))))))(((((())(()(())))((()(()))((())(()(())))))(((()(()))((())(()(()))))(((())(()(())))((()(()))((())(()(())))))))((((()(()))((())(()(()))))(((())(()(())))((()(()))((())(()(()))))))((((())(()(())))((()(()))((())(()(())))))(((()(()))((())(()(()))))(((())(()(())))((()(()))((())(()(()))))))))))))))
diff --git a/tests/sav/error_operators.res b/tests/sav/error_operators.res
new file mode 100644 (file)
index 0000000..1949e18
--- /dev/null
@@ -0,0 +1,54 @@
+error_operators.nit:17,6: Error: mandatory return type for `unary +`.
+error_operators.nit:18,6: Error: mandatory return type for `+`.
+error_operators.nit:19,6: Error: mandatory return type for `unary -`.
+error_operators.nit:20,6: Error: mandatory return type for `-`.
+error_operators.nit:21,6: Error: mandatory return type for `*`.
+error_operators.nit:22,6: Error: mandatory return type for `/`.
+error_operators.nit:23,6: Error: mandatory return type for `%`.
+error_operators.nit:24,6: Error: mandatory return type for `<`.
+error_operators.nit:25,6: Error: mandatory return type for `>`.
+error_operators.nit:26,6--7: Error: mandatory return type for `<=`.
+error_operators.nit:27,6--7: Error: mandatory return type for `>=`.
+error_operators.nit:28,6--8: Error: mandatory return type for `<=>`.
+error_operators.nit:29,6--7: Error: mandatory return type for `<<`.
+error_operators.nit:30,6--7: Error: mandatory return type for `>>`.
+error_operators.nit:32,6--7: Error: mandatory return type for `[]`.
+error_operators.nit:40,9: Syntax Error: binary operator `*` requires exactly one parameter; got 0.
+error_operators.nit:41,9: Syntax Error: binary operator `/` requires exactly one parameter; got 0.
+error_operators.nit:42,9: Syntax Error: binary operator `%` requires exactly one parameter; got 0.
+error_operators.nit:43,9: Syntax Error: binary operator `<` requires exactly one parameter; got 0.
+error_operators.nit:44,9: Syntax Error: binary operator `>` requires exactly one parameter; got 0.
+error_operators.nit:45,10: Syntax Error: binary operator `<=` requires exactly one parameter; got 0.
+error_operators.nit:46,10: Syntax Error: binary operator `>=` requires exactly one parameter; got 0.
+error_operators.nit:47,11: Syntax Error: binary operator `<=>` requires exactly one parameter; got 0.
+error_operators.nit:48,10: Syntax Error: binary operator `<<` requires exactly one parameter; got 0.
+error_operators.nit:49,10: Syntax Error: binary operator `>>` requires exactly one parameter; got 0.
+error_operators.nit:50,14: Syntax Error: `foo=` requires at least 1 parameter(s); got 0.
+error_operators.nit:51,10: Syntax Error: `[]` requires at least 1 parameter(s); got 0.
+error_operators.nit:52,9--14: Syntax Error: `[]=` requires at least 2 parameter(s); got 1.
+error_operators.nit:57,7--18: Syntax Error: binary operator `+` requires exactly one parameter; got 3.
+error_operators.nit:58,7--18: Syntax Error: binary operator `-` requires exactly one parameter; got 3.
+error_operators.nit:59,7--18: Syntax Error: binary operator `*` requires exactly one parameter; got 3.
+error_operators.nit:60,7--18: Syntax Error: binary operator `/` requires exactly one parameter; got 3.
+error_operators.nit:61,7--18: Syntax Error: binary operator `%` requires exactly one parameter; got 3.
+error_operators.nit:62,7--18: Syntax Error: binary operator `<` requires exactly one parameter; got 3.
+error_operators.nit:63,7--18: Syntax Error: binary operator `>` requires exactly one parameter; got 3.
+error_operators.nit:64,8--19: Syntax Error: binary operator `<=` requires exactly one parameter; got 3.
+error_operators.nit:65,8--19: Syntax Error: binary operator `>=` requires exactly one parameter; got 3.
+error_operators.nit:66,9--20: Syntax Error: binary operator `<=>` requires exactly one parameter; got 3.
+error_operators.nit:67,8--19: Syntax Error: binary operator `<<` requires exactly one parameter; got 3.
+error_operators.nit:68,8--19: Syntax Error: binary operator `>>` requires exactly one parameter; got 3.
+error_operators.nit:76,8--13: Error: illegal variadic parameter `a: A...` for `+`.
+error_operators.nit:77,8--13: Error: illegal variadic parameter `a: A...` for `-`.
+error_operators.nit:78,8--13: Error: illegal variadic parameter `a: A...` for `*`.
+error_operators.nit:79,8--13: Error: illegal variadic parameter `a: A...` for `/`.
+error_operators.nit:80,8--13: Error: illegal variadic parameter `a: A...` for `%`.
+error_operators.nit:81,8--13: Error: illegal variadic parameter `a: A...` for `<`.
+error_operators.nit:82,8--13: Error: illegal variadic parameter `a: A...` for `>`.
+error_operators.nit:83,9--14: Error: illegal variadic parameter `a: A...` for `<=`.
+error_operators.nit:84,9--14: Error: illegal variadic parameter `a: A...` for `>=`.
+error_operators.nit:85,10--15: Error: illegal variadic parameter `a: A...` for `<=>`.
+error_operators.nit:86,9--14: Error: illegal variadic parameter `a: A...` for `<<`.
+error_operators.nit:87,9--14: Error: illegal variadic parameter `a: A...` for `>>`.
+error_operators.nit:88,20--25: Error: illegal variadic parameter `d: A...` for `foo=`.
+error_operators.nit:90,19--24: Error: illegal variadic parameter `d: A...` for `[]=`.
diff --git a/tests/sav/nitg-e/base_autocast_array_alt2.res b/tests/sav/nitg-e/base_autocast_array_alt2.res
new file mode 100644 (file)
index 0000000..91b441c
--- /dev/null
@@ -0,0 +1,3 @@
+Runtime error: Cast failed (alt/base_autocast_array_alt2.nit:45)
+10
+10
index e80f5de..893e1ea 100644 (file)
@@ -20,6 +20,8 @@ false
 false
 true
 true
+32
+8
 52
 456
 123
index dc72c30..5cbab16 100644 (file)
@@ -11,8 +11,8 @@ true
 2
 0
 * test 2 *
-1000
-334
+100
+34
 * test 3 *
 * start:
 true
index dabb78b..48cdded 100644 (file)
@@ -10,8 +10,8 @@ true
 2
 0
 * test 2 *
-1000
-334
+100
+34
 * test 3 *
 * start:
 true
index a9be79e..2a5b99a 100644 (file)
@@ -1 +1 @@
-1234567891011121314151617181920212223
+12345678910
index 5789941..43e3636 100644 (file)
@@ -1,4 +1,4 @@
-Runtime error: Cast failed. Expected `E`, got `Bool` (../lib/standard/collection/array.nit:911)
+Runtime error: Cast failed. Expected `E`, got `Bool` (../lib/standard/collection/array.nit:960)
 NativeString
 N
 Nit
index 6e0ca35..ad80c05 100644 (file)
@@ -5,7 +5,7 @@ _DUMMY_TOOL()
        COMPREPLY=()
        cur="${COMP_WORDS[COMP_CWORD]}"
        prev="${COMP_WORDS[COMP_CWORD-1]}"
-       opts="--warn --warning --quiet --stop-on-first-error --no-color --log --log-dir --nit-dir --help --version --set-dummy-tool --verbose --bash-completion --stub-man --option-a --option-b"
+       opts="--warn --warning --quiet --stop-on-first-error --keep-going --no-color --log --log-dir --nit-dir --help --version --set-dummy-tool --verbose --bash-completion --stub-man --option-a --option-b"
        if [[ ${cur} == -* ]] ; then
                COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
                return 0
index b14caf6..464f929 100644 (file)
@@ -4,6 +4,7 @@ Test for ToolContext, try --bash-completion.
   -w, --warning           Show/hide a specific warning
   -q, --quiet             Do not show warnings
   --stop-on-first-error   Stop on first error
+  --keep-going            Continue after errors, whatever the consequences
   --no-color              Do not use color to display errors and warnings
   --log                   Generate various log files
   --log-dir               Directory where to generate log files
index 271589e..5261b5e 100644 (file)
@@ -102,14 +102,16 @@ class A
                return A_value( recv ) <= A_value( other );
        `}
 
-       fun >>( other : A ) import value, value=, A `{
+       fun >>( other : A ): A import value, value=, A `{
                int new_val = A_value( recv ) >> A_value( other );
                A_value__assign( recv, new_val );
+               return recv;
        `}
 
-       fun <<( other : A ) import value, A `{
+       fun <<( other : A ): A import value, A `{
                int new_val = A_value( recv ) << A_value( other );
                A_value__assign( recv, new_val );
+               return recv;
        `}
 
        fun []( index : Int ) : A import A `{
@@ -154,13 +156,13 @@ print new A( 1 ) >= new A( 100 ) # false
 print new A( 100 ) >= new A( 100 ) # true
 print new A( 100 ) >= new A( 1 ) # true
 
-#var x = new A( 1 )
-#x << new A( 5 )
-#print x # 16
+var x = new A( 1 )
+x = x << new A( 5 )
+print x # 32
 
-#var y = new A( 32 )
-#y >> new A( 2 )
-#print y # 8
+var y = new A( 32 )
+y = y >> new A( 2 )
+print y # 8
 
 var a = new A( 456 )
 print a[ 52 ] # 52
index c5b9eea..8e147f7 100644 (file)
@@ -40,7 +40,7 @@ end
 fun test2(h: Map[Int, Int])
 do
        print("* test 2 *")
-       var nb = 999
+       var nb = 99
        
        var i = 0
        while i <= nb do
index 9487e82..dc9d167 100644 (file)
@@ -27,4 +27,7 @@ fun foo(n: Int): List[Int]
        return a
     end
 
-print(foo(23))
+var n = 10
+if args.not_empty then n = args.first.to_i
+
+print(foo(n))