mirror of
https://github.com/golang/go
synced 2024-11-23 13:50:06 -07:00
1737aef270
This change adds line position tests for several yyerror calls in the typechecker that are currently not tested in any way. Untested yyerror calls were found by replacing them with yerrorl(src.NoXPos, ...) (thus destroying position information in the error), and then running the test suite. No failures means no test coverage for the relevant yyerror call. For #19683 Change-Id: Iedb3d2f02141b332e9bfa76dbf5ae930ad2fddc3 Reviewed-on: https://go-review.googlesource.com/41477 Run-TryBot: Alberto Donizetti <alb.donizetti@gmail.com> Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
68 lines
1.4 KiB
Go
68 lines
1.4 KiB
Go
// errorcheck
|
|
|
|
// Copyright 2011 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.
|
|
|
|
// Test map declarations of many types, including erroneous ones.
|
|
// Does not compile.
|
|
|
|
package main
|
|
|
|
type v bool
|
|
|
|
var (
|
|
// valid
|
|
_ map[int8]v
|
|
_ map[uint8]v
|
|
_ map[int16]v
|
|
_ map[uint16]v
|
|
_ map[int32]v
|
|
_ map[uint32]v
|
|
_ map[int64]v
|
|
_ map[uint64]v
|
|
_ map[int]v
|
|
_ map[uint]v
|
|
_ map[uintptr]v
|
|
_ map[float32]v
|
|
_ map[float64]v
|
|
_ map[complex64]v
|
|
_ map[complex128]v
|
|
_ map[bool]v
|
|
_ map[string]v
|
|
_ map[chan int]v
|
|
_ map[*int]v
|
|
_ map[struct{}]v
|
|
_ map[[10]int]v
|
|
|
|
// invalid
|
|
_ map[[]int]v // ERROR "invalid map key"
|
|
_ map[func()]v // ERROR "invalid map key"
|
|
_ map[map[int]int]v // ERROR "invalid map key"
|
|
_ map[T1]v // ERROR "invalid map key"
|
|
_ map[T2]v // ERROR "invalid map key"
|
|
_ map[T3]v // ERROR "invalid map key"
|
|
_ map[T4]v // ERROR "invalid map key"
|
|
_ map[T5]v
|
|
_ map[T6]v
|
|
_ map[T7]v
|
|
_ map[T8]v
|
|
)
|
|
|
|
type T1 []int
|
|
type T2 struct { F T1 }
|
|
type T3 []T4
|
|
type T4 struct { F T3 }
|
|
|
|
type T5 *int
|
|
type T6 struct { F T5 }
|
|
type T7 *T4
|
|
type T8 struct { F *T7 }
|
|
|
|
func main() {
|
|
m := make(map[int]int)
|
|
delete() // ERROR "missing arguments"
|
|
delete(m) // ERROR "missing second \(key\) argument"
|
|
delete(m, 2, 3) // ERROR "too many arguments"
|
|
delete(1, m) // ERROR "first argument to delete must be map"
|
|
} |