Debian Codegraph @

gopls/internal/test/marker/testdata/inlayhints/ignored-error.txt

raw
1 Test of "ignore error" inlay hint (#73930).
2
3 - f.Close() generates a hint, except when followed by
4 an "// ignore error" comment, or in a "_ = f.Close()" stmt.
5 - fmt.Println() is exempted.
6
7 -- settings.json --
8 {"hints": {"ignoredError": true}}
9
10 -- p/p.go --
11 package p //@inlayhints(out)
12
13 import ( "os"; "fmt" )
14
15 func _(f *os.File) {
16 f.WriteString("hello")
17 f.Close()
18 }
19
20 func _(f *os.File) {
21 f.Close() // irrelevant comment
22 }
23
24 func _(f *os.File) {
25 f.Close() // ignore error
26 }
27
28 func _(f *os.File) {
29 _ = f.Close()
30 }
31
32 func _() {
33 fmt.Println()
34 }
35
36 func _(f *os.File) {
37 // Allow horizontal space before comment.
38 new(os.File).Close() // ignore error
39 f.Close() // ignore error
40 }
41
42 -- @out --
43 package p //@inlayhints(out)
44
45 import ( "os"; "fmt" )
46
47 func _(f *os.File) {
48 f.WriteString("hello")< // ignore error>
49 f.Close()< // ignore error>
50 }
51
52 func _(f *os.File) {
53 f.Close()< // ignore error> // irrelevant comment
54 }
55
56 func _(f *os.File) {
57 f.Close() // ignore error
58 }
59
60 func _(f *os.File) {
61 _ = f.Close()
62 }
63
64 func _() {
65 fmt.Println()
66 }
67
68 func _(f *os.File) {
69 // Allow horizontal space before comment.
70 new(os.File).Close() // ignore error
71 f.Close() // ignore error
72 }
73