Skip to content

Commit

Permalink
Fixed accidental shadowing in the else branches of type assertions. L…
Browse files Browse the repository at this point in the history
…ocked staticcheck version.
  • Loading branch information
dop251 committed Mar 31, 2022
1 parent 8a7c4f4 commit 451b4e4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ jobs:
- name: Run go vet
run: go vet ./...
- name: Run staticcheck
uses: dominikh/staticcheck-action@v1.0.0
uses: dominikh/staticcheck-action@v1.1.0
with:
version: "2022.1"
install-go: false
cache-key: ${{ matrix.go-version }}
if: ${{ matrix.go-version == '1.x' }}
Expand Down
10 changes: 5 additions & 5 deletions vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -3086,10 +3086,10 @@ func (vm *vm) alreadyDeclared(name unistring.String) Value {
func (vm *vm) checkBindVarsGlobal(names []unistring.String) {
o := vm.r.globalObject.self
sn := vm.r.global.stash.names
if o, ok := o.(*baseObject); ok {
if bo, ok := o.(*baseObject); ok {
// shortcut
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))
}
if _, exists := sn[name]; exists {
Expand All @@ -3115,10 +3115,10 @@ func (vm *vm) createGlobalVarBindings(names []unistring.String, d bool) {
vm.r.global.varNames = globalVarNames
}
o := vm.r.globalObject.self
if o, ok := o.(*baseObject); ok {
if bo, ok := o.(*baseObject); ok {
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{}{}
}
Expand Down

0 comments on commit 451b4e4

Please sign in to comment.