Now that Go 1.22.6 is the minimum bootstrap toolchain (cf. CL 606156),
the slices package (introduced in Go 1.21) can be used in packages built
using the bootstrap toolchain.
For #64751
Change-Id: I0115213da4b1f0a1fa0ef7ad34456fbf52e00fae
Reviewed-on: https://go-review.googlesource.com/c/go/+/611095
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
"fmt"
"os"
"path/filepath"
+ "slices"
"strconv"
"strings"
"text/scanner"
in.Error("bad syntax in definition for macro:", name)
}
arg := in.Stack.Text()
- if i := lookup(args, arg); i >= 0 {
+ if slices.Contains(args, arg) {
in.Error("duplicate argument", arg, "in definition for macro:", name)
}
args = append(args, arg)
return args, tokens
}
-func lookup(args []string, arg string) int {
- for i, a := range args {
- if a == arg {
- return i
- }
- }
- return -1
-}
-
// invokeMacro pushes onto the input Stack a Slice that holds the macro definition with the actual
// parameters substituted for the formals.
// Invoking a macro does not touch the PC/line history.