// Copyright 2014 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 issues

import "fmt"

func issue7035() {
	type T struct{ X int }
	_ = func() {
		fmt.Println() // must refer to imported fmt rather than the fmt below
	}
	fmt := new(T)
	_ = fmt.X
}

func issue8066() {
	const (
		// TODO(gri) Enable test below for releases 1.4 and higher
		// _ = float32(340282356779733661637539395458142568447)
		_ = float32(340282356779733661637539395458142568448 /* ERROR cannot convert */ )
	)
}

// Check that a missing identifier doesn't lead to a spurious error cascade.
func issue8799a() {
	x, ok := missing /* ERROR undeclared */ ()
	_ = !ok
	_ = x
}

func issue8799b(x int, ok bool) {
	x, ok = missing /* ERROR undeclared */ ()
	_ = !ok
	_ = x
}

func issue9182() {
	type Point C /* ERROR undeclared */ .Point
	// no error for composite literal based on unknown type
	_ = Point{x: 1, y: 2}
}

func f0() (a []int)         { return }
func f1() (a []int, b int)  { return }
func f2() (a, b []int)      { return }

func append_([]int, ...int) {}

func issue9473(a []int, b ...int) {
	// variadic builtin function
	_ = append(f0())
	_ = append(f0(), f0()...)
	_ = append(f1())
	_ = append(f2 /* ERROR cannot pass argument */ ())
	_ = append(f2()... /* ERROR cannot use ... */ )
	_ = append(f0(), f1 /* ERROR 2-valued expression */ ())
	_ = append(f0(), f2 /* ERROR 2-valued expression */ ())
	_ = append(f0(), f1()... /* ERROR cannot use ... */ )
	_ = append(f0(), f2()... /* ERROR cannot use ... */ )

	// variadic user-defined function
	append_(f0())
	append_(f0(), f0()...)
	append_(f1())
	append_(f2 /* ERROR cannot pass argument */ ())
	append_(f2()... /* ERROR cannot use ... */ )
	append_(f0(), f1 /* ERROR 2-valued expression */ ())
	append_(f0(), f2 /* ERROR 2-valued expression */ ())
	append_(f0(), f1()... /* ERROR cannot use */ )
	append_(f0(), f2()... /* ERROR cannot use */ )
}

// Check that embedding a non-interface type in an interface results in a good error message.
func issue10979() {
	type _ interface {
		int /* ERROR int is not an interface */
	}
	type T struct{}
	type _ interface {
		T /* ERROR T is not an interface */
	}
	type _ interface {
		nosuchtype /* ERROR undeclared name: nosuchtype */
	}
	type _ interface {
		fmt /* ERROR Nosuchtype not declared by package fmt */ .Nosuchtype
	}
	type _ interface {
		nosuchpkg /* ERROR undeclared name: nosuchpkg */ .Nosuchtype
	}
	type I interface {
		I /* ERROR I\.m \(value of type func\(I\)\) is not a type */ .m
		m()
	}
}
