]> Cypherpunks repositories - gostls13.git/commitdiff
go/printer: fix sync bug - avoid sending on errors twice -
authorRuss Cox <rsc@golang.org>
Thu, 24 Sep 2009 08:37:27 +0000 (01:37 -0700)
committerRuss Cox <rsc@golang.org>
Thu, 24 Sep 2009 08:37:27 +0000 (01:37 -0700)
and report node type in error

R=gri
DELTA=4  (3 added, 0 deleted, 1 changed)
OCL=34949
CL=34955

src/pkg/go/printer/printer.go

index 4fdb2af342b1d9a836e13b7a10b954f1b406ec82..3c9f32405c97bf8b73762c8ef9cf002751a171c7 100644 (file)
@@ -14,6 +14,7 @@ import (
        "io";
        "os";
        "reflect";
+       "runtime";
        "strings";
        "tabwriter";
 )
@@ -105,6 +106,7 @@ func (p *printer) write0(data []byte) {
        p.written += n;
        if err != nil {
                p.errors <- err;
+               runtime.Goexit();
        }
 }
 
@@ -1402,7 +1404,8 @@ func Fprint(output io.Writer, node interface{}, mode uint, tabwidth int) (int, o
                        p.comment = n.Comments;
                        p.file(n);
                default:
-                       p.errors <- os.NewError("unsupported node type");
+                       p.errors <- os.NewError(fmt.Sprintf("unsupported node type %T", n));
+                       runtime.Goexit();
                }
                p.flush(inf);
                p.errors <- nil;  // no errors