aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/cmd/compile/internal/syntax/nodes.go2
-rw-r--r--src/cmd/compile/internal/syntax/parser.go4
-rw-r--r--src/cmd/compile/internal/syntax/printer.go9
3 files changed, 4 insertions, 11 deletions
diff --git a/src/cmd/compile/internal/syntax/nodes.go b/src/cmd/compile/internal/syntax/nodes.go
index f190e8aec9..0aeb3ddd60 100644
--- a/src/cmd/compile/internal/syntax/nodes.go
+++ b/src/cmd/compile/internal/syntax/nodes.go
@@ -336,7 +336,7 @@ type (
Init SimpleStmt
Cond Expr
Then []Stmt
- Else []Stmt
+ Else Stmt // either *IfStmt or *BlockStmt
stmt
}
diff --git a/src/cmd/compile/internal/syntax/parser.go b/src/cmd/compile/internal/syntax/parser.go
index d9cc96ed54..78df06f533 100644
--- a/src/cmd/compile/internal/syntax/parser.go
+++ b/src/cmd/compile/internal/syntax/parser.go
@@ -1634,9 +1634,9 @@ func (p *parser) ifStmt() *IfStmt {
if p.got(_Else) {
if p.tok == _If {
- s.Else = []Stmt{p.ifStmt()}
+ s.Else = p.ifStmt()
} else {
- s.Else = p.stmtBody("else clause")
+ s.Else = p.blockStmt()
}
}
diff --git a/src/cmd/compile/internal/syntax/printer.go b/src/cmd/compile/internal/syntax/printer.go
index 73459b27ad..ce3377afc1 100644
--- a/src/cmd/compile/internal/syntax/printer.go
+++ b/src/cmd/compile/internal/syntax/printer.go
@@ -534,14 +534,7 @@ func (p *printer) printRawNode(n Node) {
p.print(n.Cond, blank)
p.printBody(n.Then)
if n.Else != nil {
- p.print(blank, _Else, blank)
- if len(n.Else) == 1 {
- if n, ok := n.Else[0].(*IfStmt); ok {
- p.print(n)
- break
- }
- }
- p.printBody(n.Else)
+ p.print(blank, _Else, blank, n.Else)
}
case *SwitchStmt: