From 349798d6d1165cdf7ab21c690af4da0ddd15a5eb Mon Sep 17 00:00:00 2001 From: Jean Privat Date: Tue, 10 Nov 2015 09:54:04 -0500 Subject: [PATCH] model: accept multiple vararg parameters Signed-off-by: Jean Privat --- src/model/model.nit | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/model/model.nit b/src/model/model.nit index ccb7522..49ababd 100644 --- a/src/model/model.nit +++ b/src/model/model.nit @@ -1818,16 +1818,26 @@ class MSignature for i in [0..mparameters.length[ do var parameter = mparameters[i] if parameter.is_vararg then - assert vararg_rank == -1 + if vararg_rank >= 0 then + # If there is more than one vararg, + # consider that additional arguments cannot be mapped. + vararg_rank = -1 + break + end vararg_rank = i end end self.vararg_rank = vararg_rank end - # The rank of the ellipsis (`...`) for vararg (starting from 0). + # The rank of the main ellipsis (`...`) for vararg (starting from 0). # value is -1 if there is no vararg. # Example: for "(a: Int, b: Bool..., c: Char)" #-> vararg_rank=1 + # + # From a model POV, a signature can contain more than one vararg parameter, + # the `vararg_rank` just indicates the one that will receive the additional arguments. + # However, currently, if there is more that one vararg parameter, no one will be the main one, + # and additional arguments will be refused. var vararg_rank: Int is noinit # The number of parameters -- 1.7.9.5