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:
parent
8b16ca18d8
commit
3c8bf4f87c
|
@ -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")
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user