1
0
mirror of https://github.com/golang/go synced 2024-11-22 00:44:39 -07:00

fix a bug: do not print a ';' after a label if there wasn't one

R=r
OCL=25526
CL=25528
This commit is contained in:
Robert Griesemer 2009-02-27 16:28:36 -08:00
parent 3689e221e8
commit fadf159a81

View 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++;
}