diff --git a/compiler_test.go b/compiler_test.go index bbacbf4a..22215f2e 100644 --- a/compiler_test.go +++ b/compiler_test.go @@ -4113,6 +4113,17 @@ func TestArrowUseStrict(t *testing.T) { } } +func TestParameterOverride(t *testing.T) { + const SCRIPT = ` + function f(arg) { + var arg = arg || "default" + return arg + } + f() + ` + testScript1(SCRIPT, asciiString("default"), t) +} + /* func TestBabel(t *testing.T) { src, err := ioutil.ReadFile("babel7.js") diff --git a/vm.go b/vm.go index 43b6799d..fb95a81c 100644 --- a/vm.go +++ b/vm.go @@ -2326,7 +2326,7 @@ func (r *resolveMixedStack) exec(vm *vm) { if r.idx > 0 { idx = vm.sb + vm.args + r.idx } else { - idx = vm.sb + r.idx + idx = vm.sb - r.idx } ref = newStashRef(r.typ, r.name, (*[]Value)(&vm.stack), idx)