| // errorcheck -0 -l -d=defer |
| // Copyright 2019 The Go Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style |
| // license that can be found in the LICENSE file. |
| // check that open-coded defers are used in expected situations |
| for i := 0; i < 10; i++ { |
| defer func() { // ERROR "open-coded defer" |
| defer func() { // ERROR "heap-allocated defer" |
| defer func() { // ERROR "stack-allocated defer" |
| defer func() { // ERROR "stack-allocated defer" |
| defer func() { // ERROR "heap-allocated defer" |
| defer func() { // ERROR "open-coded defer" |
| defer func() { // ERROR "heap-allocated defer" |
| // The current analysis doesn't end a backward goto loop, so this defer is |
| // considered to be inside a loop |
| defer func() { // ERROR "heap-allocated defer" |