1
0
mirror of https://github.com/robertkrimen/otto synced 2025-10-12 20:27:30 +08:00

Fix Arguments initialization

Should contain what was passed, not exactly what was declared
This commit is contained in:
Robert Krimen 2013-06-02 16:25:17 -07:00
parent 8b16ca18d8
commit 3c8bf4f87c
2 changed files with 13 additions and 9 deletions

View File

@ -254,11 +254,15 @@ func TestObject_keys(t *testing.T) {
Object.keys(ghi);
`, "ghi")
if false {
test(`
(function(abc, def, ghi){
return Object.keys(arguments)
})(undefined, undefined);
`, "0,1")
}
test(`
(function(abc, def, ghi){
return Object.keys(arguments)
})(undefined, undefined);
`, "0,1")
test(`
(function(abc, def, ghi){
return Object.keys(arguments)
})(undefined, undefined, undefined, undefined);
`, "0,1,2,3")
}

View File

@ -124,7 +124,7 @@ func (self *_runtime) PutValue(reference _reference, value Value) {
func (self *_runtime) _callNode(function *_object, environment *_functionEnvironment, node *_functionNode, this Value, argumentList []Value) Value {
indexOfParameterName := make([]string, len(node.ParameterList))
indexOfParameterName := make([]string, len(argumentList))
// function(abc, def, ghi)
// indexOfParameterName[0] = "abc"
// indexOfParameterName[1] = "def"
@ -135,8 +135,8 @@ func (self *_runtime) _callNode(function *_object, environment *_functionEnviron
value := UndefinedValue()
if index < len(argumentList) {
value = argumentList[index]
indexOfParameterName[index] = name
}
indexOfParameterName[index] = name
self.localSet(name, value)
}