mirror of
https://github.com/golang/go
synced 2024-11-26 16:46:58 -07:00
cmd/compile/internal/types2: avoid follow-on errors for invalid [...] array
Fixes #42987. Change-Id: Iaaa46e1f79525cd1e418c1a81a6414d11f8120b5 Reviewed-on: https://go-review.googlesource.com/c/go/+/311889 Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
This commit is contained in:
parent
617a83ec68
commit
48b368b01f
@ -326,7 +326,7 @@ func TestTypesInfo(t *testing.T) {
|
|||||||
{brokenPkg + `x2; func _() { var a, b string; type x struct {f string}; z := &x{f: a, f: b,}}`, `b`, `string`},
|
{brokenPkg + `x2; func _() { var a, b string; type x struct {f string}; z := &x{f: a, f: b,}}`, `b`, `string`},
|
||||||
{brokenPkg + `x3; var x = panic("");`, `panic`, `func(interface{})`},
|
{brokenPkg + `x3; var x = panic("");`, `panic`, `func(interface{})`},
|
||||||
{`package x4; func _() { panic("") }`, `panic`, `func(interface{})`},
|
{`package x4; func _() { panic("") }`, `panic`, `func(interface{})`},
|
||||||
{brokenPkg + `x5; func _() { var x map[string][...]int; x = map[string][...]int{"": {1,2,3}} }`, `x`, `map[string][-1]int`},
|
{brokenPkg + `x5; func _() { var x map[string][...]int; x = map[string][...]int{"": {1,2,3}} }`, `x`, `map[string]invalid type`},
|
||||||
|
|
||||||
// parameterized functions
|
// parameterized functions
|
||||||
{genericPkg + `p0; func f[T any](T); var _ = f[int]`, `f`, `func[T₁ interface{}](T₁)`},
|
{genericPkg + `p0; func f[T any](T); var _ = f[int]`, `f`, `func[T₁ interface{}](T₁)`},
|
||||||
|
8
src/cmd/compile/internal/types2/fixedbugs/issue42987.src
Normal file
8
src/cmd/compile/internal/types2/fixedbugs/issue42987.src
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
// Copyright 2021 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.
|
||||||
|
|
||||||
|
// Check that there is only one error (no follow-on errors).
|
||||||
|
|
||||||
|
package p
|
||||||
|
var _ = [ /* ERROR invalid use of .* array */ ...]byte("foo")
|
@ -518,7 +518,10 @@ func (check *Checker) typInternal(e0 syntax.Expr, def *Named) (T Type) {
|
|||||||
typ.len = -1
|
typ.len = -1
|
||||||
}
|
}
|
||||||
typ.elem = check.varType(e.Elem)
|
typ.elem = check.varType(e.Elem)
|
||||||
|
if typ.len >= 0 {
|
||||||
return typ
|
return typ
|
||||||
|
}
|
||||||
|
// report error if we encountered [...]
|
||||||
|
|
||||||
case *syntax.SliceType:
|
case *syntax.SliceType:
|
||||||
typ := new(Slice)
|
typ := new(Slice)
|
||||||
|
Loading…
Reference in New Issue
Block a user