mirror of
https://github.com/golang/go
synced 2024-11-13 16:50:23 -07:00
24967ec122
Map keys are currently validated in multiple locations but share a common validation routine. The problem is that early validations should be lenient enough to allow for forward types while the final validations should not. The final validations should fail on forward types since they've already settled. This change also separates the key type checking from the creation of the map via typMap. Instead of the mapqueue being populated in copytype() by checking the map line number, it's populated in the same block that validates the key type. This isolates key validation logic while type checking. Fixes #14988 Change-Id: Ia47cf6213585d6c63b3a35249104c0439feae658 Reviewed-on: https://go-review.googlesource.com/21830 Reviewed-by: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
14 lines
368 B
Go
14 lines
368 B
Go
// errorcheck
|
|
|
|
// Copyright 2016 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.
|
|
|
|
// Issue 14988: defining a map with an invalid forward declaration array
|
|
// key doesn't cause a fatal.
|
|
|
|
package main
|
|
|
|
type m map[k]int // ERROR "invalid map key type"
|
|
type k [1]m
|