1 // Copyright 2019 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
5 // This file contains tests for the errorsas checker.
13 func (myError) Error() string { return "" }
15 func perr() *error { return nil }
17 type iface interface {
21 func two() (error, interface{}) { return nil, nil }
31 errors.As(nil, &e) // *error
32 errors.As(nil, &m) // *T where T implemements error
33 errors.As(nil, &f) // *interface
34 errors.As(nil, perr()) // *error, via a call
35 errors.As(nil, ei) // empty interface
37 errors.As(nil, nil) // want `second argument to errors.As must be a non-nil pointer to either a type that implements error, or to any interface type`
38 errors.As(nil, e) // want `second argument to errors.As must be a non-nil pointer to either a type that implements error, or to any interface type`
39 errors.As(nil, m) // want `second argument to errors.As must be a non-nil pointer to either a type that implements error, or to any interface type`
40 errors.As(nil, f) // want `second argument to errors.As must be a non-nil pointer to either a type that implements error, or to any interface type`
41 errors.As(nil, &i) // want `second argument to errors.As must be a non-nil pointer to either a type that implements error, or to any interface type`