Browse Source

Fixed accidental shadowing in the else branches of type assertions. Locked staticcheck version.

Dmitry Panov 3 years ago
parent
commit
451b4e4cab
2 changed files with 7 additions and 6 deletions
  1. 2 1
      .github/workflows/main.yml
  2. 5 5
      vm.go

+ 2 - 1
.github/workflows/main.yml

@@ -21,8 +21,9 @@ jobs:
       - name: Run go vet
       - name: Run go vet
         run: go vet ./...
         run: go vet ./...
       - name: Run staticcheck
       - name: Run staticcheck
-        uses: dominikh/staticcheck-action@v1.0.0
+        uses: dominikh/staticcheck-action@v1.1.0
         with:
         with:
+          version: "2022.1"
           install-go: false
           install-go: false
           cache-key: ${{ matrix.go-version }}
           cache-key: ${{ matrix.go-version }}
         if: ${{ matrix.go-version == '1.x' }}
         if: ${{ matrix.go-version == '1.x' }}

+ 5 - 5
vm.go

@@ -3086,10 +3086,10 @@ func (vm *vm) alreadyDeclared(name unistring.String) Value {
 func (vm *vm) checkBindVarsGlobal(names []unistring.String) {
 func (vm *vm) checkBindVarsGlobal(names []unistring.String) {
 	o := vm.r.globalObject.self
 	o := vm.r.globalObject.self
 	sn := vm.r.global.stash.names
 	sn := vm.r.global.stash.names
-	if o, ok := o.(*baseObject); ok {
+	if bo, ok := o.(*baseObject); ok {
 		// shortcut
 		// shortcut
 		for _, name := range names {
 		for _, name := range names {
-			if !o.hasOwnPropertyStr(name) && !o.extensible {
+			if !bo.hasOwnPropertyStr(name) && !bo.extensible {
 				panic(vm.r.NewTypeError("Cannot define global variable '%s', global object is not extensible", name))
 				panic(vm.r.NewTypeError("Cannot define global variable '%s', global object is not extensible", name))
 			}
 			}
 			if _, exists := sn[name]; exists {
 			if _, exists := sn[name]; exists {
@@ -3115,10 +3115,10 @@ func (vm *vm) createGlobalVarBindings(names []unistring.String, d bool) {
 		vm.r.global.varNames = globalVarNames
 		vm.r.global.varNames = globalVarNames
 	}
 	}
 	o := vm.r.globalObject.self
 	o := vm.r.globalObject.self
-	if o, ok := o.(*baseObject); ok {
+	if bo, ok := o.(*baseObject); ok {
 		for _, name := range names {
 		for _, name := range names {
-			if !o.hasOwnPropertyStr(name) && o.extensible {
-				o._putProp(name, _undefined, true, true, d)
+			if !bo.hasOwnPropertyStr(name) && bo.extensible {
+				bo._putProp(name, _undefined, true, true, d)
 			}
 			}
 			globalVarNames[name] = struct{}{}
 			globalVarNames[name] = struct{}{}
 		}
 		}