diff options
author | Keith Randall <khr@golang.org> | 2024-03-28 08:47:52 -0700 |
---|---|---|
committer | Keith Randall <khr@golang.org> | 2024-03-28 22:06:51 +0000 |
commit | 8f618c1f5329bd81912f8f776cb8bf028c750687 (patch) | |
tree | 279faa182298dd8f516dbb56106117168ba0967b /test | |
parent | 3f90ba7f1f0ecb230105ad1068ffdc3c2f9a8a97 (diff) | |
download | go-8f618c1f5329bd81912f8f776cb8bf028c750687.tar.gz go-8f618c1f5329bd81912f8f776cb8bf028c750687.zip |
cmd/compile: put constants before variables in initialization order
Fixes #66575
Change-Id: I03f4d4577b88ad0a92b260b2efd0cb9fe5082b2f
Reviewed-on: https://go-review.googlesource.com/c/go/+/575075
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/fixedbugs/issue66575.go | 31 | ||||
-rw-r--r-- | test/fixedbugs/issue66575.out | 2 |
2 files changed, 33 insertions, 0 deletions
diff --git a/test/fixedbugs/issue66575.go b/test/fixedbugs/issue66575.go new file mode 100644 index 0000000000..1ad6ca0b70 --- /dev/null +++ b/test/fixedbugs/issue66575.go @@ -0,0 +1,31 @@ +// run + +// 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 main + +var ( + v0 = initv0() + v1 = initv1() +) + +const c = "c" + +func initv0() string { + println("initv0") + if c != "" { // have a dependency on c + return "" + } + return "" +} + +func initv1() string { + println("initv1") + return "" +} + +func main() { + // do nothing +} diff --git a/test/fixedbugs/issue66575.out b/test/fixedbugs/issue66575.out new file mode 100644 index 0000000000..36d1f17a68 --- /dev/null +++ b/test/fixedbugs/issue66575.out @@ -0,0 +1,2 @@ +initv0 +initv1 |