github.com/v2fly/tools@v0.100.0/internal/lsp/analysis/undeclaredname/testdata/src/a/a.go (about)

     1  // Copyright 2020 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.
     4  
     5  package undeclared
     6  
     7  func x() int {
     8  	var z int
     9  	z = y // want "undeclared name: y"
    10  
    11  	if z == m { // want "undeclared name: m"
    12  		z = 1
    13  	}
    14  
    15  	if z == 1 {
    16  		z = 1
    17  	} else if z == n+1 { // want "undeclared name: n"
    18  		z = 1
    19  	}
    20  
    21  	switch z {
    22  	case 10:
    23  		z = 1
    24  	case a: // want "undeclared name: a"
    25  		z = 1
    26  	}
    27  	return z
    28  }