1
0
mirror of https://github.com/golang/go synced 2024-11-17 15:24:43 -07:00

go/types: fix panic when using multiple type arguments

Fix a panic caused by using type arguments without first unpacking.

This was noticed in the review of CL 300998, but unfortunately not yet
fixed.

Fixes #45635

Change-Id: I8ab1720f3e27a6002bc925f0eea943ec6f778341
Reviewed-on: https://go-review.googlesource.com/c/go/+/311669
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
This commit is contained in:
Rob Findley 2021-04-19 19:10:09 -04:00 committed by Robert Findley
parent 3711ea0b5d
commit 9f87943424
2 changed files with 11 additions and 1 deletions

View File

@ -10,6 +10,7 @@ import (
"fmt" "fmt"
"go/ast" "go/ast"
"go/constant" "go/constant"
"go/internal/typeparams"
"go/token" "go/token"
"math" "math"
) )
@ -1435,7 +1436,7 @@ func (check *Checker) exprInternal(x *operand, e ast.Expr, hint Type) exprKind {
case *ast.IndexExpr: case *ast.IndexExpr:
check.exprOrType(x, e.X) check.exprOrType(x, e.X)
if x.mode == invalid { if x.mode == invalid {
check.use(e.Index) check.use(typeparams.UnpackExpr(e.Index)...)
goto Error goto Error
} }

View File

@ -0,0 +1,9 @@
// 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.
package main
func main() {
some /* ERROR "undeclared name" */ [int, int]()
}