an access to an out-of-range argument should return undefined.
but it's not supported at this time and the runtime crashes.
(function(a) {
print(a); ///=Value::UNDEFINED
})();
currently, the arguments are passed by using a pointer to a list of Values allocated on the stack.
and the length of the list is equal to the number of arguments which may be less than the number of formal parameters.
as a result, the out-of-range access occurs.
there are multiple solutions to solve this issue.
but we don't know which one is the best at this point.
- allocating the list of
Values which has an enough number of elements (min(#arguments, #formal-parameters))
- some kind of trick is needed because the arguments should be evaluated before evaliating the function itself
- checking the number of arguments before accessing an element
- this solution may increase execution time
- generating an lamba function for each possible number of arguments
- in the function body, every access to an out-of-range argument is returned
undefined without checking the number of argument at runtime