Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(978)

Delta Between Two Patch Sets: cmd/vet/testdata/print.go

Issue 12936046: code review 12936046: go.tools/cmd/vet: check for recursive stringers (Closed)
Left Patch Set: Created 10 years, 7 months ago
Right Patch Set: diff -r 7cdd043fad2b https://code.google.com/p/go.tools Created 10 years, 7 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Right: Side by side diff | Download
« no previous file with change/comment | « cmd/vet/print.go ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
1 // Copyright 2010 The Go Authors. All rights reserved. 1 // Copyright 2010 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 // This file contains tests for the printf checker. 5 // This file contains tests for the printf checker.
6 6
7 package testdata 7 package testdata
8 8
9 import ( 9 import (
10 "fmt" 10 "fmt"
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 var notPercentDV notPercentDStruct 262 var notPercentDV notPercentDStruct
263 263
264 // A data type we can print with "%s". 264 // A data type we can print with "%s".
265 type percentSStruct struct { 265 type percentSStruct struct {
266 a string 266 a string
267 b []byte 267 b []byte
268 c stringerarray 268 c stringerarray
269 } 269 }
270 270
271 var percentSV percentSStruct 271 var percentSV percentSStruct
272
273 type recursiveStringer int
274
275 func (s recursiveStringer) String() string {
276 fmt.Sprintf("%v", &s) // ERROR "arg &s for printf causes recursive call to String method"
277 fmt.Sprintf("%d", s)
278 fmt.Sprintf("%v", s) // ERROR "arg s for printf causes recursive call to String method"
279 return fmt.Sprintln(s) // ERROR "arg s for print causes recursive call t o String method"
280 }
281
282 type recursivePtrStringer int
283
284 func (p *recursivePtrStringer) String() string {
285 fmt.Sprintf("%v", *p) // ERROR "arg \*p for printf causes recursive cal l to String method"
286 return fmt.Sprintln(p) // ERROR "arg p for print causes recursive call t o String method"
287 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b