Skip to content

Commit

Permalink
go/types: don't use user string as format string
Browse files Browse the repository at this point in the history
Fixes #60500.

Change-Id: I272c71071f239d5c9472e19ae25461001e7f6a8f
Reviewed-on: https://go-review.googlesource.com/c/go/+/499275
Reviewed-by: Robert Griesemer <[email protected]>
Run-TryBot: Robert Griesemer <[email protected]>
Auto-Submit: Robert Griesemer <[email protected]>
TryBot-Result: Gopher Robot <[email protected]>
Reviewed-by: Robert Findley <[email protected]>
  • Loading branch information
griesemer authored and gopherbot committed May 30, 2023
1 parent c99fee0 commit 0445497
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/go/types/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ func newErrorf(at positioner, code Code, format string, args ...any) *error_ {
}

func (check *Checker) error(at positioner, code Code, msg string) {
check.report(newErrorf(at, code, msg))
check.report(newErrorf(at, code, "%s", msg))
}

func (check *Checker) errorf(at positioner, code Code, format string, args ...any) {
Expand Down
11 changes: 11 additions & 0 deletions src/internal/types/testdata/fixedbugs/issue60500.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Copyright 2023 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 p

func _() {
log("This is a test %v" /* ERROR "cannot use \"This is a test %v\" (untyped string constant) as bool value in argument to log" */, "foo")
}

func log(enabled bool, format string, args ...any)

0 comments on commit 0445497

Please sign in to comment.