Helpers.argList allow check for empty list

This commit is contained in:
2022-12-16 00:35:03 +00:00
parent 1ee7f8db8b
commit 573c006876

View File

@@ -705,8 +705,12 @@ class Helpers {
};
}
public static function argList(exp:ReaderExp, forThis:String):Array<ReaderExp> {
public static function argList(exp:ReaderExp, forThis:String, allowEmpty = true):Array<ReaderExp> {
return switch (exp.def) {
case ListExp([]) if (allowEmpty):
[];
case ListExp([]) if (!allowEmpty):
throw KissError.fromExp(exp, 'arg list for $forThis must not be empty');
case ListExp(argExps):
argExps;
default: