From 96b6e78ea906001a31d03d0acbfc4a4f20eb7db9 Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Thu, 24 Aug 2023 11:58:58 +0200 Subject: [PATCH] cmd/compile/internal/syntax: use strings.LastIndexByte in trailingDigits MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously, strings.LastIndexByte couldn't be used because it was only added in Go 1.5 but Go 1.4 was required for bootstrapping. In Go 1.18, the bootstrap toolchain was bumped to Go 1.17 (see #44505), thus strings.LastIndexByte can be used now. Change-Id: I01a70a59dbfc853cf03d49747a2dd62d21ba74e9 Reviewed-on: https://go-review.googlesource.com/c/go/+/522197 Reviewed-by: Ian Lance Taylor Run-TryBot: Tobias Klauser Reviewed-by: Matthew Dempsky Auto-Submit: Tobias Klauser TryBot-Result: Gopher Robot Reviewed-by: Daniel Martí --- src/cmd/compile/internal/syntax/parser.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/cmd/compile/internal/syntax/parser.go b/src/cmd/compile/internal/syntax/parser.go index 7085287cad0..913a2f164cb 100644 --- a/src/cmd/compile/internal/syntax/parser.go +++ b/src/cmd/compile/internal/syntax/parser.go @@ -181,10 +181,9 @@ func commentText(s string) string { } func trailingDigits(text string) (uint, uint, bool) { - // Want to use LastIndexByte below but it's not defined in Go1.4 and bootstrap fails. - i := strings.LastIndex(text, ":") // look from right (Windows filenames may contain ':') + i := strings.LastIndexByte(text, ':') // look from right (Windows filenames may contain ':') if i < 0 { - return 0, 0, false // no ":" + return 0, 0, false // no ':' } // i >= 0 n, err := strconv.ParseUint(text[i+1:], 10, 0)