case *ast.FuncLit:
if sig, ok := check.typ(e.Type).(*Signature); ok {
- // Anonymous functions are considered part of the
- // init expression/func declaration which contains
- // them: use existing package-level declaration info.
- decl := check.decl // capture for use in closure below
- iota := check.iota // capture for use in closure below (#22345)
- // Don't type-check right away because the function may
- // be part of a type definition to which the function
- // body refers. Instead, type-check as soon as possible,
- // but before the enclosing scope contents changes (#22992).
- check.later(func() {
- check.funcBody(decl, "<function literal>", sig, e.Body, iota)
- })
+ if !check.conf.IgnoreFuncBodies && e.Body != nil {
+ // Anonymous functions are considered part of the
+ // init expression/func declaration which contains
+ // them: use existing package-level declaration info.
+ decl := check.decl // capture for use in closure below
+ iota := check.iota // capture for use in closure below (#22345)
+ // Don't type-check right away because the function may
+ // be part of a type definition to which the function
+ // body refers. Instead, type-check as soon as possible,
+ // but before the enclosing scope contents changes (#22992).
+ check.later(func() {
+ check.funcBody(decl, "<function literal>", sig, e.Body, iota)
+ })
+ }
x.mode = value
x.typ = sig
} else {
)
func (check *Checker) funcBody(decl *declInfo, name string, sig *Signature, body *ast.BlockStmt, iota constant.Value) {
+ if check.conf.IgnoreFuncBodies {
+ panic("internal error: function body not ignored")
+ }
+
if trace {
check.trace(body.Pos(), "--- %s: %s", name, sig)
defer func() {