Commit 4459624f authored by Robert Griesemer's avatar Robert Griesemer

bug fix: allow function types as operands

R=rsc
DELTA=10  (5 added, 0 deleted, 5 changed)
OCL=34662
CL=34666
parent bcfc6e63
...@@ -873,12 +873,17 @@ func (p *parser) parseStringList(x *ast.BasicLit) []*ast.BasicLit { ...@@ -873,12 +873,17 @@ func (p *parser) parseStringList(x *ast.BasicLit) []*ast.BasicLit {
} }
func (p *parser) parseFuncLit() ast.Expr { func (p *parser) parseFuncTypeOrLit() ast.Expr {
if p.trace { if p.trace {
defer un(trace(p, "FuncLit")); defer un(trace(p, "FuncTypeOrLit"));
} }
typ := p.parseFuncType(); typ := p.parseFuncType();
if p.tok != token.LBRACE {
// function type only
return typ;
}
p.exprLev++; p.exprLev++;
body := p.parseBlockStmt(nil); body := p.parseBlockStmt(nil);
p.optSemi = false; // function body requires separating ";" p.optSemi = false; // function body requires separating ";"
...@@ -918,10 +923,10 @@ func (p *parser) parseOperand() ast.Expr { ...@@ -918,10 +923,10 @@ func (p *parser) parseOperand() ast.Expr {
return &ast.ParenExpr{lparen, x, rparen}; return &ast.ParenExpr{lparen, x, rparen};
case token.FUNC: case token.FUNC:
return p.parseFuncLit(); return p.parseFuncTypeOrLit();
default: default:
t := p.tryRawType(true); // could be type for composite literal t := p.tryRawType(true); // could be type for composite literal or conversion
if t != nil { if t != nil {
return t; return t;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment