Merge: Handle gracefuly multi-varargs
authorJean Privat <jean@pryen.org>
Thu, 12 Nov 2015 01:43:38 +0000 (20:43 -0500)
committerJean Privat <jean@pryen.org>
Thu, 12 Nov 2015 01:43:38 +0000 (20:43 -0500)
commita3c4be9daed4086b5b027e073ad8dbe432bcbac8
tree41c10c5a2a924ae1c5cc43986f11811370d1a93c
parentb12bfddafad6a63a4ba0ffe67d6dc26914a4aac7
parent872b872cb5c0ace1c1d13a7247eb58bb36f56449
Merge: Handle gracefuly multi-varargs

This solve a very borderline issue when a signature contains more than one vararg parameter.
They are still refused in the common case but can occurs when multiple initializers are combined into a single constructor.

The implemented semantic is the following:

* vararg parameters remains varag
* if more than one vararg parameter exists in a signature, then the signature does not accepts additional arguments, it means that each vararg is associated to a single argument (a discarded alternative was to only keep the first/last parameter as the main vararg one)
* the associated argument can be either a single value, of a reverse vararg with an ellipsis.

~~~nit
class A
   fun x(i: Int...) is autoinit do end
   fun y(j: Int...) is autoinit do end
end
var a
a = new A(10, 20) # OK: i=[10], j=[20]
a = new A(10, 11, 20) # Refused
a = new A([10, 11]..., 20) # OK: i=[10, 11], j=[20]
a = new A([10, 11]..., [20, 21, 22]...) # OK: i=[10, 11], j=[20, 21, 22]
a = new A([10, 11], [20, 21, 22]) # Refused but a hint is given that `...` may be missing
~~~

Pull-Request: #1825
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>
src/compiler/abstract_compiler.nit