Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
4459624f
Commit
4459624f
authored
Sep 15, 2009
by
Robert Griesemer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bug fix: allow function types as operands
R=rsc DELTA=10 (5 added, 0 deleted, 5 changed) OCL=34662 CL=34666
parent
bcfc6e63
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
4 deletions
+9
-4
src/pkg/go/parser/parser.go
src/pkg/go/parser/parser.go
+9
-4
No files found.
src/pkg/go/parser/parser.go
View file @
4459624f
...
...
@@ -873,12 +873,17 @@ func (p *parser) parseStringList(x *ast.BasicLit) []*ast.BasicLit {
}
func
(
p
*
parser
)
parseFuncLit
()
ast
.
Expr
{
func
(
p
*
parser
)
parseFunc
TypeOr
Lit
()
ast
.
Expr
{
if
p
.
trace
{
defer
un
(
trace
(
p
,
"FuncLit"
));
defer
un
(
trace
(
p
,
"Func
TypeOr
Lit"
));
}
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
.
parseFunc
TypeOr
Lit
();
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
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment