From: Robert Griesemer Date: Tue, 15 Sep 2009 23:16:34 +0000 (-0700) Subject: bug fix: allow function types as operands X-Git-Tag: weekly.2009-11-06~569 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=4459624f046b1363bfd4258031a237a867fc58ab;p=gostls13.git bug fix: allow function types as operands R=rsc DELTA=10 (5 added, 0 deleted, 5 changed) OCL=34662 CL=34666 --- diff --git a/src/pkg/go/parser/parser.go b/src/pkg/go/parser/parser.go index 3ed25065f7..76682db950 100644 --- a/src/pkg/go/parser/parser.go +++ b/src/pkg/go/parser/parser.go @@ -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; }