Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
golang
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
golang
Commits
82f2b36e
Commit
82f2b36e
authored
Dec 06, 2012
by
David Symonds
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vet: be less strict about number of arguments when a ... is present.
R=golang-dev CC=golang-dev
https://golang.org/cl/6883046
parent
4fb78c3a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
0 deletions
+10
-0
print.go
src/cmd/vet/print.go
+10
-0
No files found.
src/cmd/vet/print.go
View file @
82f2b36e
...
...
@@ -120,6 +120,10 @@ func (f *File) checkPrintf(call *ast.CallExpr, name string, skip int) {
}
}
expect
:=
len
(
call
.
Args
)
-
(
skip
+
1
)
// Don't be too strict on dotdotdot.
if
call
.
Ellipsis
.
IsValid
()
&&
numArgs
>=
expect
{
return
}
if
numArgs
!=
expect
{
f
.
Badf
(
call
.
Pos
(),
"wrong number of args in %s call: %d needed but %d args"
,
name
,
numArgs
,
expect
)
}
...
...
@@ -280,6 +284,7 @@ func BadFunctionUsedInTests() {
fmt
.
Printf
(
"%s%%%d"
,
"hi"
,
3
)
// correct
fmt
.
Printf
(
"%.*d"
,
3
,
3
)
// correct
fmt
.
Printf
(
"%.*d"
,
3
,
3
,
3
)
// ERROR "wrong number of args in Printf call"
fmt
.
Printf
(
"%q %q"
,
multi
()
...
)
// ok
printf
(
"now is the time"
,
"buddy"
)
// ERROR "no formatting directive"
Printf
(
"now is the time"
,
"buddy"
)
// ERROR "no formatting directive"
Printf
(
"hi"
)
// ok
...
...
@@ -297,3 +302,8 @@ func BadFunctionUsedInTests() {
func
printf
(
format
string
,
args
...
interface
{})
{
panic
(
"don't call - testing only"
)
}
// multi is used by the test.
func
multi
()
[]
interface
{}
{
panic
(
"don't call - testing only"
)
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment