mirror of
https://github.com/peklaiho/madlisp.git
synced 2024-11-26 15:14:12 +00:00
fix argument validation messages
This commit is contained in:
parent
0f64d24074
commit
e1298ba5ec
@ -27,17 +27,15 @@ class CoreFunc extends Func
|
|||||||
|
|
||||||
private function validateArgs(int $count)
|
private function validateArgs(int $count)
|
||||||
{
|
{
|
||||||
if ($this->minArgs >= 0 && $count < $this->minArgs) {
|
if ($this->minArgs == $this->maxArgs && $count != $this->minArgs) {
|
||||||
if ($this->minArgs == $this->maxArgs) {
|
throw new MadLispException(sprintf("%s requires exactly %s argument%s", $this->name, $this->minArgs,
|
||||||
throw new MadLispException(sprintf("%s requires exactly %s argument%s", $this->name, $this->minArgs,
|
$this->minArgs == 1 ? '' : 's'));
|
||||||
$this->minArgs == 1 ? '' : 's'));
|
} elseif ($count < $this->minArgs) {
|
||||||
} else {
|
throw new MadLispException(sprintf("%s requires at least %s argument%s", $this->name, $this->minArgs,
|
||||||
throw new MadLispException(sprintf("%s requires at least %s argument%s", $this->name, $this->minArgs,
|
$this->minArgs == 1 ? '' : 's'));
|
||||||
$this->minArgs == 1 ? '' : 's'));
|
|
||||||
}
|
|
||||||
} elseif ($this->maxArgs >= 0 && $count > $this->maxArgs) {
|
} elseif ($this->maxArgs >= 0 && $count > $this->maxArgs) {
|
||||||
throw new MadLispException(sprintf("%s requires at most %s argument%s", $this->name, $this->maxArgs,
|
throw new MadLispException(sprintf("%s requires at most %s argument%s", $this->name, $this->maxArgs,
|
||||||
$this->maxArgs == 1 ? '' : 's'));
|
$this->maxArgs == 1 ? '' : 's'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user