]> Cypherpunks repositories - gostls13.git/commitdiff
fix a bug: do not print a ';' after a label if there wasn't one
authorRobert Griesemer <gri@golang.org>
Sat, 28 Feb 2009 00:28:36 +0000 (16:28 -0800)
committerRobert Griesemer <gri@golang.org>
Sat, 28 Feb 2009 00:28:36 +0000 (16:28 -0800)
R=r
OCL=25526
CL=25528

usr/gri/pretty/printer.go

index 8f270216efaede1b1989523226b959c7ec75be8d..f08e70ccdb771925796674689f4d78274974b724 100644 (file)
@@ -760,7 +760,7 @@ func (P *Printer) StatementList(list *vector.Vector) {
                if i == 0 {
                        P.newlines = 1;
                } else {  // i > 0
-                       if !P.opt_semi {
+                       if !P.opt_semi || *optsemicolons {
                                // semicolon is required
                                P.separator = semicolon;
                        }
@@ -806,6 +806,10 @@ func (P *Printer) DoLabelDecl(s *AST.LabelDecl) {
        P.indentation--;
        P.Expr(s.Label);
        P.Token(s.Pos, Scanner.COLON);
+       // TODO not quite correct:
+       // - we must not print this optional semicolon, as it may invalidate code.
+       // - this will change once the AST reflects the LabelStatement change
+       P.opt_semi = true;
        P.indentation++;
 }