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 {
}
func (p *parser) parseFuncLit() ast.Expr {
func (p *parser) parseFuncTypeOrLit() ast.Expr {
if p.trace {
defer un(trace(p, "FuncLit"));
defer un(trace(p, "FuncTypeOrLit"));
}
typ := p.parseFuncType();
if p.tok != token.LBRACE {
// function type only
return typ;
}
p.exprLev++;
body := p.parseBlockStmt(nil);
p.optSemi = false; // function body requires separating ";"
......@@ -918,10 +923,10 @@ func (p *parser) parseOperand() ast.Expr {
return &ast.ParenExpr{lparen, x, rparen};
case token.FUNC:
return p.parseFuncLit();
return p.parseFuncTypeOrLit();
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 {
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