Update to go1.23.4
This commit is contained in:
@@ -318,9 +318,10 @@ func containsClosure(f, c *ir.Func) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// Closures within function Foo are named like "Foo.funcN..." or "Foo-rangeN".
|
||||
// TODO(mdempsky): Better way to recognize this.
|
||||
fn := f.Sym().Name
|
||||
cn := c.Sym().Name
|
||||
return len(cn) > len(fn) && cn[:len(fn)] == fn && (cn[len(fn)] == '.' || cn[len(fn)] == '-')
|
||||
for p := c.ClosureParent; p != nil; p = p.ClosureParent {
|
||||
if p == f {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -582,6 +582,23 @@ func TestIssue25596(t *testing.T) {
|
||||
compileAndImportPkg(t, "issue25596")
|
||||
}
|
||||
|
||||
func TestIssue70394(t *testing.T) {
|
||||
testenv.MustHaveGoBuild(t)
|
||||
|
||||
// This package only handles gc export data.
|
||||
if runtime.Compiler != "gc" {
|
||||
t.Skipf("gc-built packages not available (compiler = %s)", runtime.Compiler)
|
||||
}
|
||||
|
||||
pkg := compileAndImportPkg(t, "alias")
|
||||
obj := lookupObj(t, pkg.Scope(), "A")
|
||||
|
||||
typ := obj.Type()
|
||||
if _, ok := typ.(*types2.Alias); !ok {
|
||||
t.Fatalf("type of %s is %s, wanted an alias", obj, typ)
|
||||
}
|
||||
}
|
||||
|
||||
func importPkg(t *testing.T, path, srcDir string) *types2.Package {
|
||||
pkg, err := Import(make(map[string]*types2.Package), path, srcDir, nil)
|
||||
if err != nil {
|
||||
|
||||
7
src/cmd/compile/internal/importer/testdata/alias.go
vendored
Normal file
7
src/cmd/compile/internal/importer/testdata/alias.go
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
// Copyright 2024 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 testdata
|
||||
|
||||
type A = int32
|
||||
@@ -29,11 +29,9 @@ func ReadPackage(ctxt *types2.Context, imports map[string]*types2.Package, input
|
||||
pr := pkgReader{
|
||||
PkgDecoder: input,
|
||||
|
||||
ctxt: ctxt,
|
||||
imports: imports,
|
||||
// Currently, the compiler panics when using Alias types.
|
||||
// TODO(gri) set to true once this is fixed (issue #66873)
|
||||
enableAlias: false,
|
||||
ctxt: ctxt,
|
||||
imports: imports,
|
||||
enableAlias: true,
|
||||
|
||||
posBases: make([]*syntax.PosBase, input.NumElems(pkgbits.RelocPosBase)),
|
||||
pkgs: make([]*types2.Package, input.NumElems(pkgbits.RelocPkg)),
|
||||
|
||||
@@ -51,6 +51,8 @@ import (
|
||||
// the generated ODCLFUNC, but there is no
|
||||
// pointer from the Func back to the OMETHVALUE.
|
||||
type Func struct {
|
||||
// if you add or remove a field, don't forget to update sizeof_test.go
|
||||
|
||||
miniNode
|
||||
Body Nodes
|
||||
|
||||
@@ -76,6 +78,9 @@ type Func struct {
|
||||
// Populated during walk.
|
||||
Closures []*Func
|
||||
|
||||
// Parent of a closure
|
||||
ClosureParent *Func
|
||||
|
||||
// Parents records the parent scope of each scope within a
|
||||
// function. The root scope (0) has no parent, so the i'th
|
||||
// scope's parent is stored at Parents[i-1].
|
||||
@@ -512,6 +517,7 @@ func NewClosureFunc(fpos, cpos src.XPos, why Op, typ *types.Type, outerfn *Func,
|
||||
|
||||
fn.Nname.Defn = fn
|
||||
pkg.Funcs = append(pkg.Funcs, fn)
|
||||
fn.ClosureParent = outerfn
|
||||
|
||||
return fn
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ func TestSizeof(t *testing.T) {
|
||||
_32bit uintptr // size on 32bit platforms
|
||||
_64bit uintptr // size on 64bit platforms
|
||||
}{
|
||||
{Func{}, 176, 296},
|
||||
{Func{}, 180, 304},
|
||||
{Name{}, 96, 168},
|
||||
}
|
||||
|
||||
|
||||
@@ -2099,3 +2099,27 @@ func TestTwoLevelReturnCheck(t *testing.T) {
|
||||
t.Errorf("Expected y=3, got y=%d\n", y)
|
||||
}
|
||||
}
|
||||
|
||||
func Bug70035(s1, s2, s3 []string) string {
|
||||
var c1 string
|
||||
for v1 := range slices.Values(s1) {
|
||||
var c2 string
|
||||
for v2 := range slices.Values(s2) {
|
||||
var c3 string
|
||||
for v3 := range slices.Values(s3) {
|
||||
c3 = c3 + v3
|
||||
}
|
||||
c2 = c2 + v2 + c3
|
||||
}
|
||||
c1 = c1 + v1 + c2
|
||||
}
|
||||
return c1
|
||||
}
|
||||
|
||||
func Test70035(t *testing.T) {
|
||||
got := Bug70035([]string{"1", "2", "3"}, []string{"a", "b", "c"}, []string{"A", "B", "C"})
|
||||
want := "1aABCbABCcABC2aABCbABCcABC3aABCbABCcABC"
|
||||
if got != want {
|
||||
t.Errorf("got %v, want %v", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user