diff mbox

[gccgo] Go library updates for panic recover

Message ID mcrk4q2fapj.fsf@dhcp-172-17-9-151.mtv.corp.google.com
State New
Headers show

Commit Message

Ian Lance Taylor June 14, 2010, 5:24 a.m. UTC
This patch updates the Go library for the removal of the panicln
function and the change to the panic function to take only one
argument.  It also adds the runtime.Error interface used for builtin
panics.  Committed to gccgo branch.

Ian
diff mbox

Patch

diff -r d56422877227 libgo/go/bufio/bufio.go
--- a/libgo/go/bufio/bufio.go	Sat Jun 05 10:17:15 2010 -0700
+++ b/libgo/go/bufio/bufio.go	Sun Jun 13 22:20:07 2010 -0700
@@ -75,7 +75,7 @@ 
 	b, err := NewReaderSize(rd, defaultBufSize)
 	if err != nil {
 		// cannot happen - defaultBufSize is a valid size
-		panic("bufio: NewReader: ", err.String())
+		panic(err)
 	}
 	return b
 }
@@ -353,7 +353,7 @@ 
 	b, err := NewWriterSize(wr, defaultBufSize)
 	if err != nil {
 		// cannot happen - defaultBufSize is valid size
-		panic("bufio: NewWriter: ", err.String())
+		panic(err)
 	}
 	return b
 }
diff -r d56422877227 libgo/go/bytes/bytes_test.go
--- a/libgo/go/bytes/bytes_test.go	Sat Jun 05 10:17:15 2010 -0700
+++ b/libgo/go/bytes/bytes_test.go	Sun Jun 13 22:20:07 2010 -0700
@@ -151,7 +151,8 @@ 
 	for i := 0; i < b.N; i++ {
 		j := index(buf, 'x')
 		if j != n-1 {
-			panic("bad index", j)
+			println("bad index", j)
+			panic("bad index")
 		}
 	}
 	buf[n-1] = '0'
diff -r d56422877227 libgo/go/crypto/block/cfb.go
--- a/libgo/go/crypto/block/cfb.go	Sat Jun 05 10:17:15 2010 -0700
+++ b/libgo/go/crypto/block/cfb.go	Sun Jun 13 22:20:07 2010 -0700
@@ -26,7 +26,7 @@ 
 
 func newCFB(c Cipher, s int, iv []byte) *cfbCipher {
 	if s == 0 || s%8 != 0 {
-		panicln("crypto/block: invalid CFB mode", s)
+		panic("crypto/block: invalid CFB mode")
 	}
 	b := c.BlockSize()
 	x := new(cfbCipher)
diff -r d56422877227 libgo/go/crypto/block/cmac.go
--- a/libgo/go/crypto/block/cmac.go	Sat Jun 05 10:17:15 2010 -0700
+++ b/libgo/go/crypto/block/cmac.go	Sun Jun 13 22:20:07 2010 -0700
@@ -37,7 +37,7 @@ 
 	case 128 / 8:
 		r = r128
 	default:
-		panic("crypto/block: NewCMAC: invalid cipher block size", n)
+		panic("crypto/block: NewCMAC: invalid cipher block size")
 	}
 
 	d := new(cmac)
diff -r d56422877227 libgo/go/crypto/block/eax.go
--- a/libgo/go/crypto/block/eax.go	Sat Jun 05 10:17:15 2010 -0700
+++ b/libgo/go/crypto/block/eax.go	Sun Jun 13 22:20:07 2010 -0700
@@ -36,7 +36,7 @@ 
 func setupEAX(c Cipher, iv, hdr []byte, tagBytes int) (ctrIV, tag []byte, cmac hash.Hash) {
 	n := len(iv)
 	if n != c.BlockSize() {
-		panicln("crypto/block: EAX: iv length", n, "!=", c.BlockSize())
+		panic(fmt.Sprintln("crypto/block: EAX: iv length", n, "!=", c.BlockSize()))
 	}
 	buf := make([]byte, n) // zeroed
 
diff -r d56422877227 libgo/go/crypto/block/ecb_test.go
--- a/libgo/go/crypto/block/ecb_test.go	Sat Jun 05 10:17:15 2010 -0700
+++ b/libgo/go/crypto/block/ecb_test.go	Sun Jun 13 22:20:07 2010 -0700
@@ -24,10 +24,10 @@ 
 
 func (c *IncCipher) Encrypt(src, dst []byte) {
 	if !c.encrypting {
-		panicln("encrypt: not encrypting")
+		panic("encrypt: not encrypting")
 	}
 	if len(src) != c.blockSize || len(dst) != c.blockSize {
-		panicln("encrypt: wrong block size", c.blockSize, len(src), len(dst))
+		panic(fmt.Sprintln("encrypt: wrong block size", c.blockSize, len(src), len(dst)))
 	}
 	c.delta++
 	for i, b := range src {
@@ -37,10 +37,10 @@ 
 
 func (c *IncCipher) Decrypt(src, dst []byte) {
 	if c.encrypting {
-		panicln("decrypt: not decrypting")
+		panic("decrypt: not decrypting")
 	}
 	if len(src) != c.blockSize || len(dst) != c.blockSize {
-		panicln("decrypt: wrong block size", c.blockSize, len(src), len(dst))
+		panic(fmt.Sprintln("decrypt: wrong block size ", c.blockSize, " ", len(src), " ", len(dst)))
 	}
 	c.delta--
 	for i, b := range src {
diff -r d56422877227 libgo/go/crypto/block/ofb.go
--- a/libgo/go/crypto/block/ofb.go	Sat Jun 05 10:17:15 2010 -0700
+++ b/libgo/go/crypto/block/ofb.go	Sun Jun 13 22:20:07 2010 -0700
@@ -13,6 +13,7 @@ 
 package block
 
 import (
+	"fmt"
 	"io"
 )
 
@@ -26,7 +27,7 @@ 
 	x.c = c
 	n := len(iv)
 	if n != c.BlockSize() {
-		panicln("crypto/block: newOFBStream: invalid iv size", n, "!=", c.BlockSize())
+		panic(fmt.Sprintln("crypto/block: newOFBStream: invalid iv size", n, "!=", c.BlockSize()))
 	}
 	x.iv = copy(iv)
 	return x
diff -r d56422877227 libgo/go/crypto/md4/md4.go
--- a/libgo/go/crypto/md4/md4.go	Sat Jun 05 10:17:15 2010 -0700
+++ b/libgo/go/crypto/md4/md4.go	Sun Jun 13 22:20:07 2010 -0700
@@ -99,7 +99,7 @@ 
 	d.Write(tmp[0:8])
 
 	if d.nx != 0 {
-		panicln("oops")
+		panic("d.nx != 0")
 	}
 
 	p := make([]byte, 16)
diff -r d56422877227 libgo/go/crypto/md5/md5.go
--- a/libgo/go/crypto/md5/md5.go	Sat Jun 05 10:17:15 2010 -0700
+++ b/libgo/go/crypto/md5/md5.go	Sun Jun 13 22:20:07 2010 -0700
@@ -99,7 +99,7 @@ 
 	d.Write(tmp[0:8])
 
 	if d.nx != 0 {
-		panicln("oops")
+		panic("d.nx != 0")
 	}
 
 	p := make([]byte, 16)
diff -r d56422877227 libgo/go/crypto/sha1/sha1.go
--- a/libgo/go/crypto/sha1/sha1.go	Sat Jun 05 10:17:15 2010 -0700
+++ b/libgo/go/crypto/sha1/sha1.go	Sun Jun 13 22:20:07 2010 -0700
@@ -101,7 +101,7 @@ 
 	d.Write(tmp[0:8])
 
 	if d.nx != 0 {
-		panicln("oops")
+		panic("d.nx != 0")
 	}
 
 	p := make([]byte, 20)
diff -r d56422877227 libgo/go/crypto/sha256/sha256.go
--- a/libgo/go/crypto/sha256/sha256.go	Sat Jun 05 10:17:15 2010 -0700
+++ b/libgo/go/crypto/sha256/sha256.go	Sun Jun 13 22:20:07 2010 -0700
@@ -107,7 +107,7 @@ 
 	d.Write(tmp[0:8])
 
 	if d.nx != 0 {
-		panicln("oops")
+		panic("d.nx != 0")
 	}
 
 	p := make([]byte, 32)
diff -r d56422877227 libgo/go/debug/proc/proc_linux.go
--- a/libgo/go/debug/proc/proc_linux.go	Sat Jun 05 10:17:15 2010 -0700
+++ b/libgo/go/debug/proc/proc_linux.go	Sun Jun 13 22:20:07 2010 -0700
@@ -430,7 +430,7 @@ 
 		t.logTrace("beginning wait")
 		ev.Waitmsg, ev.err = os.Wait(t.tid, syscall.WALL)
 		if ev.err == nil && ev.Pid != t.tid {
-			panic("Wait returned pid ", ev.Pid, " wanted ", t.tid)
+			panic(fmt.Sprint("Wait returned pid ", ev.Pid, " wanted ", t.tid))
 		}
 		if ev.StopSignal() == syscall.SIGSTOP && t.ignoreNextSigstop {
 			// Spurious SIGSTOP.  See Thread.Stop().
diff -r d56422877227 libgo/go/debug/proc/regs_linux_386.go
--- a/libgo/go/debug/proc/regs_linux_386.go	Sat Jun 05 10:17:15 2010 -0700
+++ b/libgo/go/debug/proc/regs_linux_386.go	Sun Jun 13 22:20:07 2010 -0700
@@ -92,7 +92,7 @@ 
 	case 15:
 		return Word(r.Gs)
 	}
-	panic("invalid register index ", strconv.Itoa(i))
+	panic("invalid register index " + strconv.Itoa(i))
 }
 
 func (r *_386Regs) Set(i int, val Word) os.Error {
@@ -130,7 +130,7 @@ 
 	case 15:
 		r.Gs = uint16(val)
 	default:
-		panic("invalid register index ", strconv.Itoa(i))
+		panic("invalid register index " + strconv.Itoa(i))
 	}
 	return r.setter(&r.PtraceRegs)
 }
diff -r d56422877227 libgo/go/debug/proc/regs_linux_amd64.go
--- a/libgo/go/debug/proc/regs_linux_amd64.go	Sat Jun 05 10:17:15 2010 -0700
+++ b/libgo/go/debug/proc/regs_linux_amd64.go	Sun Jun 13 22:20:07 2010 -0700
@@ -124,7 +124,7 @@ 
 	case 23:
 		return Word(r.Gs)
 	}
-	panic("invalid register index ", strconv.Itoa(i))
+	panic("invalid register index " + strconv.Itoa(i))
 }
 
 func (r *amd64Regs) Set(i int, val Word) os.Error {
@@ -178,7 +178,7 @@ 
 	case 23:
 		r.Gs = uint64(val)
 	default:
-		panic("invalid register index ", strconv.Itoa(i))
+		panic("invalid register index " + strconv.Itoa(i))
 	}
 	return r.setter(&r.PtraceRegs)
 }
diff -r d56422877227 libgo/go/exp/eval/abort.go
--- a/libgo/go/exp/eval/abort.go	Sat Jun 05 10:17:15 2010 -0700
+++ b/libgo/go/exp/eval/abort.go	Sun Jun 13 22:20:07 2010 -0700
@@ -14,7 +14,7 @@ 
 // causing the innermost Try to return err.
 func (t *Thread) Abort(err os.Error) {
 	if t.abort == nil {
-		panicln("abort:", err.String())
+		panic("abort: " + err.String())
 	}
 	t.abort <- err
 	runtime.Goexit()
diff -r d56422877227 libgo/go/exp/eval/eval_test.go
--- a/libgo/go/exp/eval/eval_test.go	Sat Jun 05 10:17:15 2010 -0700
+++ b/libgo/go/exp/eval/eval_test.go	Sun Jun 13 22:20:07 2010 -0700
@@ -196,7 +196,7 @@ 
 		return &funcV{val}
 	}
 	log.Crashf("toValue(%T) not implemented", val)
-	panic()
+	panic("unreachable")
 }
 
 /*
diff -r d56422877227 libgo/go/exp/eval/expr.go
--- a/libgo/go/exp/eval/expr.go	Sat Jun 05 10:17:15 2010 -0700
+++ b/libgo/go/exp/eval/expr.go	Sun Jun 13 22:20:07 2010 -0700
@@ -6,6 +6,7 @@ 
 
 import (
 	"bignum"
+	"fmt"
 	"go/ast"
 	"go/token"
 	"log"
@@ -340,7 +341,7 @@ 
 		temp := b.DefineTemp(a.rmt)
 		tempIdx := temp.Index
 		if tempIdx < 0 {
-			panicln("tempidx", tempIdx)
+			panic(fmt.Sprintln("tempidx", tempIdx))
 		}
 		if a.isMapUnpack {
 			rf := a.rs[0].evalMapValue
@@ -655,7 +656,7 @@ 
 		return ei.compileUnaryExpr(x.Op, v)
 	}
 	log.Crashf("unexpected ast node type %T", x)
-	panic()
+	panic("unreachable")
 
 typeexpr:
 	if !callCtx {
@@ -717,7 +718,7 @@ 
 		return nil
 	}
 	log.Crashf("name %s has unknown type %T", name, def)
-	panic()
+	panic("unreachable")
 }
 
 func (a *exprInfo) compileVariable(level int, v *Variable) *expr {
@@ -1388,12 +1389,12 @@ 
 		expr.eval = func(*Thread) Value { return t.Zero() }
 		return expr
 
-	case panicType, paniclnType, printType, printlnType:
+	case panicType, printType, printlnType:
 		evals := make([]func(*Thread) interface{}, len(as))
 		for i, x := range as {
 			evals[i] = x.asInterface()
 		}
-		spaces := ft == paniclnType || ft == printlnType
+		spaces := ft == printlnType
 		newline := ft != printType
 		printer := func(t *Thread) {
 			for i, eval := range evals {
@@ -1427,7 +1428,7 @@ 
 		}
 		expr := a.newExpr(EmptyType, "print")
 		expr.exec = printer
-		if ft == panicType || ft == paniclnType {
+		if ft == panicType {
 			expr.exec = func(t *Thread) {
 				printer(t)
 				t.Abort(os.NewError("panic"))
@@ -1437,7 +1438,7 @@ 
 	}
 
 	log.Crashf("unexpected built-in function '%s'", ft.builtin)
-	panic()
+	panic("unreachable")
 }
 
 func (a *exprInfo) compileStarExpr(v *expr) *expr {
diff -r d56422877227 libgo/go/exp/eval/expr1.go
--- a/libgo/go/exp/eval/expr1.go	Sat Jun 05 10:17:15 2010 -0700
+++ b/libgo/go/exp/eval/expr1.go	Sun Jun 13 22:20:07 2010 -0700
@@ -76,7 +76,7 @@ 
 	default:
 		log.Crashf("unexpected expression node type %T at %v", a.eval, a.pos)
 	}
-	panic()
+	panic("fail")
 }
 
 /*
@@ -214,26 +214,17 @@ 
 	switch a.t.lit().(type) {
 	case *uintType:
 		vf := v.asUint()
-		a.eval = func(t *Thread) uint64 {
-			v := vf(t)
-			return -v
-		}
+		a.eval = func(t *Thread) uint64 { v := vf(t); return -v }
 	case *intType:
 		vf := v.asInt()
-		a.eval = func(t *Thread) int64 {
-			v := vf(t)
-			return -v
-		}
+		a.eval = func(t *Thread) int64 { v := vf(t); return -v }
 	case *idealIntType:
 		v := v.asIdealInt()()
 		val := v.Neg()
 		a.eval = func() *bignum.Integer { return val }
 	case *floatType:
 		vf := v.asFloat()
-		a.eval = func(t *Thread) float64 {
-			v := vf(t)
-			return -v
-		}
+		a.eval = func(t *Thread) float64 { v := vf(t); return -v }
 	case *idealFloatType:
 		v := v.asIdealFloat()()
 		val := v.Neg()
@@ -247,10 +238,7 @@ 
 	switch a.t.lit().(type) {
 	case *boolType:
 		vf := v.asBool()
-		a.eval = func(t *Thread) bool {
-			v := vf(t)
-			return !v
-		}
+		a.eval = func(t *Thread) bool { v := vf(t); return !v }
 	default:
 		log.Crashf("unexpected type %v at %v", a.t, a.pos)
 	}
@@ -260,16 +248,10 @@ 
 	switch a.t.lit().(type) {
 	case *uintType:
 		vf := v.asUint()
-		a.eval = func(t *Thread) uint64 {
-			v := vf(t)
-			return ^v
-		}
+		a.eval = func(t *Thread) uint64 { v := vf(t); return ^v }
 	case *intType:
 		vf := v.asInt()
-		a.eval = func(t *Thread) int64 {
-			v := vf(t)
-			return ^v
-		}
+		a.eval = func(t *Thread) int64 { v := vf(t); return ^v }
 	case *idealIntType:
 		v := v.asIdealInt()()
 		val := v.Neg().Sub(bignum.Int(1))
@@ -1909,5 +1891,5 @@ 
 	default:
 		log.Crashf("unexpected left operand type %v at %v", lt, r.pos)
 	}
-	panic()
+	panic("fail")
 }
diff -r d56422877227 libgo/go/exp/eval/type.go
--- a/libgo/go/exp/eval/type.go	Sat Jun 05 10:17:15 2010 -0700
+++ b/libgo/go/exp/eval/type.go	Sun Jun 13 22:20:07 2010 -0700
@@ -231,7 +231,7 @@ 
 		res := uint64V(0)
 		return &res
 	}
-	panic("unexpected uint bit count: ", t.Bits)
+	panic("unexpected uint bit count")
 }
 
 func (t *uintType) minVal() *bignum.Rational { return bignum.Rat(0, 1) }
@@ -304,7 +304,7 @@ 
 		res := intV(0)
 		return &res
 	}
-	panic("unexpected int bit count: ", t.Bits)
+	panic("unexpected int bit count")
 }
 
 func (t *intType) minVal() *bignum.Rational {
@@ -390,7 +390,7 @@ 
 		res := floatV(0)
 		return &res
 	}
-	panic("unexpected float bit count: ", t.Bits)
+	panic("unexpected float bit count")
 }
 
 var maxFloat32Val = bignum.MakeRat(bignum.Int(0xffffff).Shl(127-23), bignum.Nat(1))
@@ -410,7 +410,7 @@ 
 		return minFloat64Val
 	}
 	log.Crashf("unexpected floating point bit count: %d", bits)
-	panic()
+	panic("unreachable")
 }
 
 func (t *floatType) maxVal() *bignum.Rational {
@@ -425,7 +425,7 @@ 
 		return maxFloat64Val
 	}
 	log.Crashf("unexpected floating point bit count: %d", bits)
-	panic()
+	panic("unreachable")
 }
 
 /*
@@ -702,7 +702,6 @@ 
 	makeType    = &FuncType{builtin: "make"}
 	newType     = &FuncType{builtin: "new"}
 	panicType   = &FuncType{builtin: "panic"}
-	paniclnType = &FuncType{builtin: "panicln"}
 	printType   = &FuncType{builtin: "print"}
 	printlnType = &FuncType{builtin: "println"}
 )
@@ -1237,7 +1236,6 @@ 
 	universe.DefineConst("make", universePos, makeType, nil)
 	universe.DefineConst("new", universePos, newType, nil)
 	universe.DefineConst("panic", universePos, panicType, nil)
-	universe.DefineConst("panicln", universePos, paniclnType, nil)
 	universe.DefineConst("print", universePos, printType, nil)
 	universe.DefineConst("println", universePos, printlnType, nil)
 }
diff -r d56422877227 libgo/go/exp/ogle/rvalue.go
--- a/libgo/go/exp/ogle/rvalue.go	Sat Jun 05 10:17:15 2010 -0700
+++ b/libgo/go/exp/ogle/rvalue.go	Sun Jun 13 22:20:07 2010 -0700
@@ -232,7 +232,7 @@ 
 	case 8:
 		return v.r.p.ToFloat64(bits)
 	}
-	panic("Unexpected float size ", v.size)
+	panic("Unexpected float size")
 }
 
 func (v remoteFloat) Set(t *eval.Thread, x float64) {
@@ -247,7 +247,7 @@ 
 	case 8:
 		bits = v.r.p.FromFloat64(x)
 	default:
-		panic("Unexpected float size ", v.size)
+		panic("Unexpected float size")
 	}
 	v.r.Set(a, v.size, bits)
 }
diff -r d56422877227 libgo/go/exp/ogle/vars.go
--- a/libgo/go/exp/ogle/vars.go	Sat Jun 05 10:17:15 2010 -0700
+++ b/libgo/go/exp/ogle/vars.go	Sun Jun 13 22:20:07 2010 -0700
@@ -63,7 +63,7 @@ 
 	}
 
 	t.Abort(NotOnStack{v.fn, g})
-	panic()
+	panic("fail")
 }
 
 func (v remoteFramePtr) Set(t *eval.Thread, x eval.Value) {
diff -r d56422877227 libgo/go/exp/parser/parser.go
--- a/libgo/go/exp/parser/parser.go	Sat Jun 05 10:17:15 2010 -0700
+++ b/libgo/go/exp/parser/parser.go	Sun Jun 13 22:20:07 2010 -0700
@@ -1624,7 +1624,7 @@ 
 		return &ast.ForStmt{pos, s1, p.makeExpr(s2), s3, body}
 	}
 
-	panic() // unreachable
+	panic("unreachable") // unreachable
 	return nil
 }
 
diff -r d56422877227 libgo/go/go/ast/walk.go
--- a/libgo/go/go/ast/walk.go	Sat Jun 05 10:17:15 2010 -0700
+++ b/libgo/go/go/ast/walk.go	Sun Jun 13 22:20:07 2010 -0700
@@ -326,7 +326,7 @@ 
 
 	default:
 		fmt.Printf("ast.Walk: unexpected type %T", n)
-		panic()
+		panic("ast.Walk")
 	}
 
 	v.Visit(nil)
diff -r d56422877227 libgo/go/go/parser/parser.go
--- a/libgo/go/go/parser/parser.go	Sat Jun 05 10:17:15 2010 -0700
+++ b/libgo/go/go/parser/parser.go	Sun Jun 13 22:20:07 2010 -0700
@@ -1743,8 +1743,7 @@ 
 		return &ast.ForStmt{pos, s1, p.makeExpr(s2), s3, body}
 	}
 
-	panic() // unreachable
-	return nil
+	panic("unreachable")
 }
 
 
diff -r d56422877227 libgo/go/go/printer/printer.go
--- a/libgo/go/go/printer/printer.go	Sat Jun 05 10:17:15 2010 -0700
+++ b/libgo/go/go/printer/printer.go	Sun Jun 13 22:20:07 2010 -0700
@@ -105,7 +105,7 @@ 
 	if debug {
 		fmt.Print(p.pos.String() + ": ")
 		fmt.Println(msg)
-		panic()
+		panic("go/printer")
 	}
 }
 
@@ -770,7 +770,8 @@ 
 				next = x // accurate position of next item
 			}
 		default:
-			panicln("print: unsupported argument type", f.Type().String())
+			fmt.Fprintf(os.Stderr, "print: unsupported argument type %T\n", f)
+			panic("go/printer type")
 		}
 		p.pos = next
 
diff -r d56422877227 libgo/go/gob/decode.go
--- a/libgo/go/gob/decode.go	Sat Jun 05 10:17:15 2010 -0700
+++ b/libgo/go/gob/decode.go	Sun Jun 13 22:20:07 2010 -0700
@@ -777,7 +777,7 @@ 
 	case unsafe.Sizeof(float64(0)):
 		op = decFloat64
 	default:
-		panic("gob: unknown size of float", unsafe.Sizeof(float(0)))
+		panic("gob: unknown size of float")
 	}
 	decOpMap[valueKind(float(0))] = op
 
@@ -791,7 +791,7 @@ 
 		op = decInt64
 		uop = decUint64
 	default:
-		panic("gob: unknown size of int/uint", unsafe.Sizeof(int(0)))
+		panic("gob: unknown size of int/uint")
 	}
 	decOpMap[valueKind(int(0))] = op
 	decOpMap[valueKind(uint(0))] = uop
@@ -803,7 +803,7 @@ 
 	case unsafe.Sizeof(uint64(0)):
 		uop = decUint64
 	default:
-		panic("gob: unknown size of uintptr", unsafe.Sizeof(uintptr(0)))
+		panic("gob: unknown size of uintptr")
 	}
 	decOpMap[valueKind(uintptr(0))] = uop
 }
diff -r d56422877227 libgo/go/gob/encode.go
--- a/libgo/go/gob/encode.go	Sat Jun 05 10:17:15 2010 -0700
+++ b/libgo/go/gob/encode.go	Sun Jun 13 22:20:07 2010 -0700
@@ -399,7 +399,7 @@ 
 func compileEnc(rt reflect.Type) (*encEngine, os.Error) {
 	srt, ok := rt.(*reflect.StructType)
 	if !ok {
-		panicln("can't happen: non-struct")
+		panic("can't happen: non-struct")
 	}
 	engine := new(encEngine)
 	engine.instr = make([]encInstr, srt.NumField()+1) // +1 for terminator
diff -r d56422877227 libgo/go/gob/type.go
--- a/libgo/go/gob/type.go	Sat Jun 05 10:17:15 2010 -0700
+++ b/libgo/go/gob/type.go	Sun Jun 13 22:20:07 2010 -0700
@@ -114,7 +114,7 @@ 
 	// Move the id space upwards to allow for growth in the predefined world
 	// without breaking existing files.
 	if nextId > firstUserId {
-		panicln("nextId too large:", nextId)
+		panic(fmt.Sprintln("nextId too large:", nextId))
 	}
 	nextId = firstUserId
 }
@@ -303,7 +303,7 @@ 
 
 func checkId(want, got typeId) {
 	if want != got {
-		panicln("bootstrap type wrong id:", got.Name(), got, "not", want)
+		panic("bootstrap type wrong id: " + got.Name() + " " + got.string() + " not " + want.string())
 	}
 }
 
@@ -312,7 +312,7 @@ 
 	rt := reflect.Typeof(e)
 	_, present := types[rt]
 	if present {
-		panicln("bootstrap type already present:", name)
+		panic("bootstrap type already present: " + name)
 	}
 	typ := &commonType{name: name}
 	types[rt] = typ
@@ -356,7 +356,7 @@ 
 // typeLock must be held.
 func getTypeInfo(rt reflect.Type) (*typeInfo, os.Error) {
 	if _, ok := rt.(*reflect.PtrType); ok {
-		panicln("pointer type in getTypeInfo:", rt.String())
+		panic("pointer type in getTypeInfo: " + rt.String())
 	}
 	info, ok := typeInfoMap[rt]
 	if !ok {
@@ -388,7 +388,7 @@ 
 func mustGetTypeInfo(rt reflect.Type) *typeInfo {
 	t, err := getTypeInfo(rt)
 	if err != nil {
-		panicln("getTypeInfo:", err.String())
+		panic("getTypeInfo: " + err.String())
 	}
 	return t
 }
diff -r d56422877227 libgo/go/gob/type_test.go
--- a/libgo/go/gob/type_test.go	Sat Jun 05 10:17:15 2010 -0700
+++ b/libgo/go/gob/type_test.go	Sun Jun 13 22:20:07 2010 -0700
@@ -28,7 +28,7 @@ 
 	defer typeLock.Unlock()
 	t, err := getType(name, rt)
 	if err != nil {
-		panicln("getTypeUnlocked:", err.String())
+		panic("getTypeUnlocked: " + err.String())
 	}
 	return t
 }
diff -r d56422877227 libgo/go/http/lex.go
--- a/libgo/go/http/lex.go	Sat Jun 05 10:17:15 2010 -0700
+++ b/libgo/go/http/lex.go	Sun Jun 13 22:20:07 2010 -0700
@@ -14,20 +14,16 @@ 
 	switch c {
 	case '(', ')', '<', '>', '@', ',', ';', ':', '\\', '"', '/', '[', ']', '?', '=', '{', '}', ' ', '\t':
 		return true
-	default:
-		return false
 	}
-	panic()
+	return false
 }
 
 func isSpace(c byte) bool {
 	switch c {
 	case ' ', '\t', '\r', '\n':
 		return true
-	default:
-		return false
 	}
-	panic()
+	return false
 }
 
 func isCtl(c byte) bool { return (0 <= c && c <= 31) || c == 127 }
diff -r d56422877227 libgo/go/http/server.go
--- a/libgo/go/http/server.go	Sat Jun 05 10:17:15 2010 -0700
+++ b/libgo/go/http/server.go	Sun Jun 13 22:20:07 2010 -0700
@@ -508,7 +508,7 @@ 
 // Handle registers the handler for the given pattern.
 func (mux *ServeMux) Handle(pattern string, handler Handler) {
 	if pattern == "" || pattern[0] != '/' {
-		panicln("http: invalid pattern", pattern)
+		panic("http: invalid pattern " + pattern)
 	}
 
 	mux.m[pattern] = handler
diff -r d56422877227 libgo/go/net/fd.go
--- a/libgo/go/net/fd.go	Sat Jun 05 10:17:15 2010 -0700
+++ b/libgo/go/net/fd.go	Sun Jun 13 22:20:07 2010 -0700
@@ -11,6 +11,7 @@ 
 	"os"
 	"sync"
 	"syscall"
+	"time"
 )
 
 // Network file descriptor.
@@ -128,7 +129,7 @@ 
 		return
 	}
 	if err := s.poll.AddFD(intfd, mode, false); err != nil {
-		panicln("pollServer AddFD ", intfd, ": ", err.String(), "\n")
+		panic("pollServer AddFD " + err.String())
 		return
 	}
 
@@ -176,12 +177,7 @@ 
 }
 
 func (s *pollServer) Now() int64 {
-	sec, nsec, err := os.Time()
-	if err != nil {
-		panic("net: os.Time: ", err.String())
-	}
-	nsec += sec * 1e9
-	return nsec
+	return time.Nanoseconds()
 }
 
 func (s *pollServer) CheckDeadlines() {
diff -r d56422877227 libgo/go/net/unixsock.go
--- a/libgo/go/net/unixsock.go	Sat Jun 05 10:17:15 2010 -0700
+++ b/libgo/go/net/unixsock.go	Sun Jun 13 22:20:07 2010 -0700
@@ -25,7 +25,7 @@ 
 	var la, ra syscall.Sockaddr
 	switch mode {
 	default:
-		panic("unixSocket", mode)
+		panic("unixSocket mode " + mode)
 
 	case "dial":
 		if laddr != nil {
diff -r d56422877227 libgo/go/reflect/tostring_test.go
--- a/libgo/go/reflect/tostring_test.go	Sat Jun 05 10:17:15 2010 -0700
+++ b/libgo/go/reflect/tostring_test.go	Sun Jun 13 22:20:07 2010 -0700
@@ -111,7 +111,7 @@ 
 		v := val
 		return typ.String() + "(" + strconv.Itoa64(int64(v.Get())) + ")"
 	default:
-		panicln("valueToString: can't print type ", typ.String())
+		panic("valueToString: can't print type " + typ.String())
 	}
 	return "valueToString: can't happen"
 }
diff -r d56422877227 libgo/go/reflect/type.go
--- a/libgo/go/reflect/type.go	Sat Jun 05 10:17:15 2010 -0700
+++ b/libgo/go/reflect/type.go	Sun Jun 13 22:20:07 2010 -0700
@@ -668,7 +668,7 @@ 
 	case *runtime.StructType:
 		return (*StructType)(unsafe.Pointer(v))
 	}
-	panicln("toType", i)
+	panic("toType")
 }
 
 // Convert pointer to runtime Type structure to our Type structure.
@@ -732,7 +732,7 @@ 
 	case runtime.StructTypeCode:
 		r = (*StructType)(unsafe.Pointer(v))
 	default:
-		panicln("runtimeToType", v)
+		panic("runtimeToType")
 	}
 	return canonicalize(r)
 }
diff -r d56422877227 libgo/go/reflect/value.go
--- a/libgo/go/reflect/value.go	Sat Jun 05 10:17:15 2010 -0700
+++ b/libgo/go/reflect/value.go	Sun Jun 13 22:20:07 2010 -0700
@@ -503,7 +503,7 @@ 
 
 func typesMustMatch(t1, t2 Type) {
 	if t1 != t2 {
-		panicln("type mismatch:", t1.String(), "!=", t2.String())
+		panic("type mismatch: " + t1.String() + " != " + t2.String())
 	}
 }
 
@@ -571,7 +571,7 @@ 
 	typ := v.typ.(*ArrayType).Elem()
 	n := v.Len()
 	if i < 0 || i >= n {
-		panic("index", i, "in array len", n)
+		panic("array index out of bounds")
 	}
 	p := addr(uintptr(v.addr()) + uintptr(i)*typ.Size())
 	return newValue(typ, p, v.canSet)
@@ -612,7 +612,7 @@ 
 func (v *SliceValue) SetLen(n int) {
 	s := v.slice()
 	if n < 0 || n > int(s.Cap) {
-		panicln("SetLen", n, "with capacity", s.Cap)
+		panic("reflect: slice length out of range in SetLen")
 	}
 	s.Len = n
 }
@@ -642,7 +642,7 @@ 
 func (v *SliceValue) Slice(beg, end int) *SliceValue {
 	cap := v.Cap()
 	if beg < 0 || end < beg || end > cap {
-		panic("slice bounds [", beg, ":", end, "] with capacity ", cap)
+		panic("slice index out of bounds")
 	}
 	typ := v.typ.(*SliceType)
 	s := new(SliceHeader)
@@ -657,7 +657,7 @@ 
 	typ := v.typ.(*SliceType).Elem()
 	n := v.Len()
 	if i < 0 || i >= n {
-		panicln("index", i, "in array of length", n)
+		panic("reflect: slice index out of range")
 	}
 	p := addr(uintptr(v.addr()) + uintptr(i)*typ.Size())
 	return newValue(typ, p, v.canSet)
@@ -985,7 +985,7 @@ 
 				j++
 			}
 			if j >= xmc {
-				panicln("no method", vm.Name)
+				panic("no method" + vm.Name)
 			}
 		}
 		pv[1] = addr(&methods[0])
@@ -1342,7 +1342,7 @@ 
 	case *UnsafePointerType:
 		return (*UnsafePointerValue)(v)
 	}
-	panicln("newValue", typ.String())
+	panic("newValue" + typ.String())
 }
 
 // MakeZero returns a zero Value for the specified Type.
diff -r d56422877227 libgo/go/regexp/regexp.go
--- a/libgo/go/regexp/regexp.go	Sat Jun 05 10:17:15 2010 -0700
+++ b/libgo/go/regexp/regexp.go	Sun Jun 13 22:20:07 2010 -0700
@@ -673,7 +673,7 @@ 
 func MustCompile(str string) *Regexp {
 	regexp, error := Compile(str)
 	if error != nil {
-		panicln(`regexp: compiling "`, str, `": `, error.String())
+		panic(`regexp: compiling "` + str + `": ` + error.String())
 	}
 	return regexp
 }
diff -r d56422877227 libgo/go/rpc/client.go
--- a/libgo/go/rpc/client.go	Sat Jun 05 10:17:15 2010 -0700
+++ b/libgo/go/rpc/client.go	Sun Jun 13 22:20:07 2010 -0700
@@ -61,7 +61,7 @@ 
 	client.enc.Encode(request)
 	err := client.enc.Encode(c.Args)
 	if err != nil {
-		panicln("rpc: client encode error:", err.String())
+		panic("rpc: client encode error: " + err.String())
 	}
 	client.sending.Unlock()
 }
diff -r d56422877227 libgo/go/rpc/server_test.go
--- a/libgo/go/rpc/server_test.go	Sat Jun 05 10:17:15 2010 -0700
+++ b/libgo/go/rpc/server_test.go	Sun Jun 13 22:20:07 2010 -0700
@@ -49,7 +49,7 @@ 
 }
 
 func (t *Arith) Error(args *Args, reply *Reply) os.Error {
-	panicln("ERROR")
+	panic("ERROR")
 }
 
 func startServer() {
diff -r d56422877227 libgo/go/runtime/error.go
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libgo/go/runtime/error.go	Sun Jun 13 22:20:07 2010 -0700
@@ -0,0 +1,131 @@ 
+// Copyright 2010 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 runtime
+
+// The Error interface identifies a run time error.
+type Error interface {
+	String() string
+
+	// RuntimeError is a no-op function but
+	// serves to distinguish types that are runtime
+	// errors from ordinary os.Errors: a type is a
+	// runtime error if it has a RuntimeError method.
+	RuntimeError()
+}
+
+// A TypeAssertionError explains a failed type assertion.
+type TypeAssertionError struct {
+	interfaceType   *Type // interface had this type
+	concreteType    *Type // concrete value had this type
+	assertedType    *Type // asserted type
+	interfaceString string
+	concreteString  string
+	assertedString  string
+	missingMethod   string // one method needed by Interface, missing from Concrete
+}
+
+func (*TypeAssertionError) RuntimeError() {}
+
+func (e *TypeAssertionError) String() string {
+	inter := e.interfaceString
+	if inter == "" {
+		inter = "interface"
+	}
+	if e.concreteType == nil {
+		return "interface conversion: " + inter + " is nil, not " + e.assertedString
+	}
+	if e.missingMethod == "" {
+		return "interface conversion: " + inter + " is " + e.concreteString +
+			", not " + e.assertedString
+	}
+	return "interface conversion: " + e.concreteString + " is not " + e.assertedString +
+		": missing method " + e.missingMethod
+}
+
+// Concrete returns the type of the concrete value in the failed type assertion.
+// If the interface value was nil, Concrete returns nil.
+func (e *TypeAssertionError) Concrete() *Type {
+	return e.concreteType
+}
+
+// Asserted returns the type incorrectly asserted by the type assertion.
+func (e *TypeAssertionError) Asserted() *Type {
+	return e.assertedType
+}
+
+// If the type assertion is to an interface type, MissingMethod returns the
+// name of a method needed to satisfy that interface type but not implemented
+// by Concrete.  If there are multiple such methods,
+// MissingMethod returns one; which one is unspecified.
+// If the type assertion is not to an interface type, MissingMethod returns an empty string.
+func (e *TypeAssertionError) MissingMethod() string {
+	return e.missingMethod
+}
+
+// For calling from C.
+func NewTypeAssertionError(pt1, pt2, pt3 *Type, ps1, ps2, ps3 *string, pmeth *string, ret *interface{}) {
+	var t1, t2, t3 *Type
+	var s1, s2, s3, meth string
+
+	if pt1 != nil {
+		t1 = pt1
+	}
+	if pt2 != nil {
+		t2 = pt2
+	}
+	if pt3 != nil {
+		t3 = pt3
+	}
+	if ps1 != nil {
+		s1 = *ps1
+	}
+	if ps2 != nil {
+		s2 = *ps2
+	}
+	if ps3 != nil {
+		s3 = *ps3
+	}
+	if pmeth != nil {
+		meth = *pmeth
+	}
+	*ret = &TypeAssertionError{t1, t2, t3, s1, s2, s3, meth}
+}
+
+// An errorString represents a runtime error described by a single string.
+type errorString string
+
+func (e errorString) RuntimeError() {}
+
+func (e errorString) String() string {
+	return "runtime error: " + string(e)
+}
+
+// For calling from C.
+func NewErrorString(s string, ret *interface{}) {
+	*ret = errorString(s)
+}
+
+type stringer interface {
+	String() string
+}
+
+// For calling from C.
+// Prints an argument passed to panic.
+// There's room for arbitrary complexity here, but we keep it
+// simple and handle just a few important cases: int, string, and Stringer.
+func Printany(i interface{}) {
+	switch v := i.(type) {
+	case nil:
+		print("nil")
+	case stringer:
+		print(v.String())
+	case int:
+		print(v)
+	case string:
+		print(v)
+	default:
+		print(i)
+	}
+}
diff -r d56422877227 libgo/go/strconv/fp_test.go
--- a/libgo/go/strconv/fp_test.go	Sat Jun 05 10:17:15 2010 -0700
+++ b/libgo/go/strconv/fp_test.go	Sun Jun 13 22:20:07 2010 -0700
@@ -96,7 +96,7 @@ 
 func TestFp(t *testing.T) {
 	f, err := os.Open("testfp.txt", os.O_RDONLY, 0)
 	if err != nil {
-		panicln("testfp: open testfp.txt:", err.String())
+		t.Fatal("testfp: open testfp.txt:", err.String())
 	}
 	defer f.Close()
 
@@ -109,7 +109,7 @@ 
 			break
 		}
 		if err2 != nil {
-			panicln("testfp: read testfp.txt:", err2.String())
+			t.Fatal("testfp: read testfp.txt: " + err2.String())
 		}
 		line = line[0 : len(line)-1]
 		lineno++
diff -r d56422877227 libgo/go/strconv/ftoa_test.go
--- a/libgo/go/strconv/ftoa_test.go	Sat Jun 05 10:17:15 2010 -0700
+++ b/libgo/go/strconv/ftoa_test.go	Sun Jun 13 22:20:07 2010 -0700
@@ -101,7 +101,8 @@ 
 
 func TestFtoa(t *testing.T) {
 	if FloatSize != 32 {
-		panic("floatsize: ", FloatSize)
+		println("floatsize: ", FloatSize)
+		panic("floatsize")
 	}
 	for i := 0; i < len(ftoatests); i++ {
 		test := &ftoatests[i]
diff -r d56422877227 libgo/go/tabwriter/tabwriter_test.go
--- a/libgo/go/tabwriter/tabwriter_test.go	Sat Jun 05 10:17:15 2010 -0700
+++ b/libgo/go/tabwriter/tabwriter_test.go	Sun Jun 13 22:20:07 2010 -0700
@@ -31,7 +31,7 @@ 
 			b.a[n+i] = buf[i]
 		}
 	} else {
-		panicln("buffer.Write: buffer too small", n, m, cap(b.a))
+		panic("buffer.Write: buffer too small")
 	}
 	return len(buf), nil
 }
diff -r d56422877227 libgo/go/template/template.go
--- a/libgo/go/template/template.go	Sat Jun 05 10:17:15 2010 -0700
+++ b/libgo/go/template/template.go	Sun Jun 13 22:20:07 2010 -0700
@@ -964,7 +964,7 @@ 
 func MustParse(s string, fmap FormatterMap) *Template {
 	t, err := Parse(s, fmap)
 	if err != nil {
-		panic("template parse error: ", err.String())
+		panic("template.MustParse error: " + err.String())
 	}
 	return t
 }
diff -r d56422877227 libgo/go/testing/regexp.go
--- a/libgo/go/testing/regexp.go	Sat Jun 05 10:17:15 2010 -0700
+++ b/libgo/go/testing/regexp.go	Sun Jun 13 22:20:07 2010 -0700
@@ -624,7 +624,7 @@ 
 func MustCompile(str string) *Regexp {
 	regexp, error := CompileRegexp(str)
 	if error != "" {
-		panicln(`regexp: compiling "`, str, `": `, error)
+		panic(`regexp: compiling "` + str + `": ` + error)
 	}
 	return regexp
 }
diff -r d56422877227 libgo/go/time/time.go
--- a/libgo/go/time/time.go	Sat Jun 05 10:17:15 2010 -0700
+++ b/libgo/go/time/time.go	Sun Jun 13 22:20:07 2010 -0700
@@ -15,7 +15,7 @@ 
 func Seconds() int64 {
 	sec, _, err := os.Time()
 	if err != nil {
-		panic("time: os.Time: ", err.String())
+		panic(err)
 	}
 	return sec
 }
@@ -25,7 +25,7 @@ 
 func Nanoseconds() int64 {
 	sec, nsec, err := os.Time()
 	if err != nil {
-		panic("time: os.Time: ", err.String())
+		panic(err)
 	}
 	return sec*1e9 + nsec
 }
diff -r d56422877227 libgo/go/websocket/client.go
--- a/libgo/go/websocket/client.go	Sat Jun 05 10:17:15 2010 -0700
+++ b/libgo/go/websocket/client.go	Sun Jun 13 22:20:07 2010 -0700
@@ -55,14 +55,14 @@ 
 	func main() {
 	 	ws, err := websocket.Dial("ws://localhost/ws", "", "http://localhost/");
 	 	if err != nil {
-			panic("Dial: ", err.String())
+			panic("Dial: " + err.String())
 		}
 		if _, err := ws.Write(strings.Bytes("hello, world!\n")); err != nil {
-			panic("Write: ", err.String())
+			panic("Write: " + err.String())
 		}
 		var msg = make([]byte, 512);
 		if n, err := ws.Read(msg); err != nil {
-			panic("Read: ", err.String())
+			panic("Read: " + err.String())
 		}
 		// use msg[0:n]
 	}
diff -r d56422877227 libgo/go/websocket/server.go
--- a/libgo/go/websocket/server.go	Sat Jun 05 10:17:15 2010 -0700
+++ b/libgo/go/websocket/server.go	Sun Jun 13 22:20:07 2010 -0700
@@ -30,7 +30,7 @@ 
 		http.Handle("/echo", websocket.Handler(EchoServer));
 		err := http.ListenAndServe(":12345", nil);
 		if err != nil {
-			panic("ListenAndServe: ", err.String())
+			panic("ListenAndServe: " + err.String())
 		}
 	}
 */
@@ -62,7 +62,7 @@ 
 
 	rwc, buf, err := c.Hijack()
 	if err != nil {
-		panic("Hijack failed: ", err.String())
+		panic("Hijack failed: " + err.String())
 		return
 	}
 	defer rwc.Close()