// Copyright 2022 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package a

import (
	"fmt"
	"os"
)

type A struct {
	b int
}

func singleAssignment() {
	if 1 == 1 {
	}

	panic("I should survive")
}

func noOtherStmtsInBlock() {
}

func partOfMultiAssignment() {
	_, err := os.Open("file") // want `f.*declared (and|but) not used`
	panic(err)
}

func sideEffects(cBool chan bool, cInt chan int) {
	<-c            // want `b.*declared (and|but) not used`
	fmt.Sprint("") // want `s.*declared (and|but) not used`
	A{             // want `a.*declared (and|but) not used`
		b: func() int {
			return 1
		}(),
	}
	A{<-cInt}          // want `c.*declared (and|but) not used`
	fInt() + <-cInt    // want `d.*declared (and|but) not used`
	fBool() && <-cBool // want `e.*declared (and|but) not used`
	map[int]int{       // want `f.*declared (and|but) not used`
		fInt(): <-cInt,
	}
	[]int{<-cInt}       // want `g.*declared (and|but) not used`
	func(s string) {}() // want `i.*declared (and|but) not used`
}

func commentAbove() {
	// v is a variable
}

func fBool() bool {
	return true
}

func fInt() int {
	return 1
}
