-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Closed
Labels
Description
by kwwaters:
What steps will reproduce the problem? 1. Try using bytes.Buffer.UnreadByte() What is the expected output? UnreadByte() unreads a byte when the last operation was a read. What do you see instead? UnreadByte() returns "UnreadByte: previous operation was not a read" Which compiler are you using (5g, 6g, 8g, gccgo)? 6g Which operating system are you using? Linux 2.6.36-gentoo-r5 Which revision are you using? (hg identify) 8eeee945e358+ release/release.2011-01-06 I looked at the source for tip and it appears to be broken as well, but I didn't try it. Please provide any additional information below. I think this patch fixes the test. diff -r 47bc23fc4855 src/pkg/bytes/buffer.go --- a/src/pkg/bytes/buffer.go Fri Jan 07 15:33:00 2011 +1100 +++ b/src/pkg/bytes/buffer.go Thu Jan 06 23:07:32 2011 -0800 @@ -291,7 +291,7 @@ // read operation. If write has happened since the last read, UnreadByte // returns an error. func (b *Buffer) UnreadByte() os.Error { - if b.lastRead == opReadRune || b.lastRead == opRead { + if b.lastRead != opReadRune && b.lastRead != opRead { return os.ErrorString("bytes.Buffer: UnreadByte: previous operation was not a read") } b.lastRead = opInvalid