github.com/v2fly/tools@v0.100.0/internal/lsp/testdata/bad/bad1.go (about)

     1  // +build go1.11
     2  
     3  package bad
     4  
     5  // See #36637
     6  type stateFunc func() stateFunc //@item(stateFunc, "stateFunc", "func() stateFunc", "type")
     7  
     8  var a unknown //@item(global_a, "a", "unknown", "var"),diag("unknown", "compiler", "undeclared name: unknown", "error")
     9  
    10  func random() int { //@item(random, "random", "func() int", "func")
    11  	//@complete("", global_a, bob, random, random2, random3, stateFunc, stuff)
    12  	return 0
    13  }
    14  
    15  func random2(y int) int { //@item(random2, "random2", "func(y int) int", "func"),item(bad_y_param, "y", "int", "var")
    16  	x := 6       //@item(x, "x", "int", "var"),diag("x", "compiler", "x declared but not used", "error")
    17  	var q blah   //@item(q, "q", "blah", "var"),diag("q", "compiler", "q declared but not used", "error"),diag("blah", "compiler", "undeclared name: blah", "error")
    18  	var t **blob //@item(t, "t", "**blob", "var"),diag("t", "compiler", "t declared but not used", "error"),diag("blob", "compiler", "undeclared name: blob", "error")
    19  	//@complete("", q, t, x, bad_y_param, global_a, bob, random, random2, random3, stateFunc, stuff)
    20  
    21  	return y
    22  }
    23  
    24  func random3(y ...int) { //@item(random3, "random3", "func(y ...int)", "func"),item(y_variadic_param, "y", "[]int", "var")
    25  	//@complete("", y_variadic_param, global_a, bob, random, random2, random3, stateFunc, stuff)
    26  
    27  	var ch chan (favType1)   //@item(ch, "ch", "chan (favType1)", "var"),diag("ch", "compiler", "ch declared but not used", "error"),diag("favType1", "compiler", "undeclared name: favType1", "error")
    28  	var m map[keyType]int    //@item(m, "m", "map[keyType]int", "var"),diag("m", "compiler", "m declared but not used", "error"),diag("keyType", "compiler", "undeclared name: keyType", "error")
    29  	var arr []favType2       //@item(arr, "arr", "[]favType2", "var"),diag("arr", "compiler", "arr declared but not used", "error"),diag("favType2", "compiler", "undeclared name: favType2", "error")
    30  	var fn1 func() badResult //@item(fn1, "fn1", "func() badResult", "var"),diag("fn1", "compiler", "fn1 declared but not used", "error"),diag("badResult", "compiler", "undeclared name: badResult", "error")
    31  	var fn2 func(badParam)   //@item(fn2, "fn2", "func(badParam)", "var"),diag("fn2", "compiler", "fn2 declared but not used", "error"),diag("badParam", "compiler", "undeclared name: badParam", "error")
    32  	//@complete("", arr, ch, fn1, fn2, m, y_variadic_param, global_a, bob, random, random2, random3, stateFunc, stuff)
    33  }