I think this is because nil itself is considered an argument to the function, so any function that depends on the number of arguments to do different things will have this behavior, including Standard Library functions like math.min:
For this function, this is by design.
You either provide 3 or 4 arguments, but all have to be of valid type.
Documentation also says that last parameter can be excluded, not that it can be substituted with nil.