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
7664ec39
Commit
7664ec39
authored
Mar 11, 2011
by
Robert Griesemer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
go/parser: first constant in a constant declaration must have a value
R=r, rsc1 CC=golang-dev
https://golang.org/cl/4291042
parent
ec713d68
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
9 deletions
+10
-9
src/pkg/go/parser/parser.go
src/pkg/go/parser/parser.go
+9
-9
src/pkg/go/parser/parser_test.go
src/pkg/go/parser/parser_test.go
+1
-0
No files found.
src/pkg/go/parser/parser.go
View file @
7664ec39
...
...
@@ -1864,10 +1864,10 @@ func (p *parser) parseStmt() (s ast.Stmt) {
// ----------------------------------------------------------------------------
// Declarations
type
parseSpecFunction
func
(
p
*
parser
,
doc
*
ast
.
CommentGroup
)
ast
.
Spec
type
parseSpecFunction
func
(
p
*
parser
,
doc
*
ast
.
CommentGroup
,
iota
int
)
ast
.
Spec
func
parseImportSpec
(
p
*
parser
,
doc
*
ast
.
CommentGroup
)
ast
.
Spec
{
func
parseImportSpec
(
p
*
parser
,
doc
*
ast
.
CommentGroup
,
_
int
)
ast
.
Spec
{
if
p
.
trace
{
defer
un
(
trace
(
p
,
"ImportSpec"
))
}
...
...
@@ -1894,7 +1894,7 @@ func parseImportSpec(p *parser, doc *ast.CommentGroup) ast.Spec {
}
func
parseConstSpec
(
p
*
parser
,
doc
*
ast
.
CommentGroup
)
ast
.
Spec
{
func
parseConstSpec
(
p
*
parser
,
doc
*
ast
.
CommentGroup
,
iota
int
)
ast
.
Spec
{
if
p
.
trace
{
defer
un
(
trace
(
p
,
"ConstSpec"
))
}
...
...
@@ -1902,7 +1902,7 @@ func parseConstSpec(p *parser, doc *ast.CommentGroup) ast.Spec {
idents
:=
p
.
parseIdentList
()
typ
:=
p
.
tryType
()
var
values
[]
ast
.
Expr
if
typ
!=
nil
||
p
.
tok
==
token
.
ASSIGN
{
if
typ
!=
nil
||
p
.
tok
==
token
.
ASSIGN
||
iota
==
0
{
p
.
expect
(
token
.
ASSIGN
)
values
=
p
.
parseExprList
()
}
...
...
@@ -1919,7 +1919,7 @@ func parseConstSpec(p *parser, doc *ast.CommentGroup) ast.Spec {
}
func
parseTypeSpec
(
p
*
parser
,
doc
*
ast
.
CommentGroup
)
ast
.
Spec
{
func
parseTypeSpec
(
p
*
parser
,
doc
*
ast
.
CommentGroup
,
_
int
)
ast
.
Spec
{
if
p
.
trace
{
defer
un
(
trace
(
p
,
"TypeSpec"
))
}
...
...
@@ -1939,7 +1939,7 @@ func parseTypeSpec(p *parser, doc *ast.CommentGroup) ast.Spec {
}
func
parseVarSpec
(
p
*
parser
,
doc
*
ast
.
CommentGroup
)
ast
.
Spec
{
func
parseVarSpec
(
p
*
parser
,
doc
*
ast
.
CommentGroup
,
_
int
)
ast
.
Spec
{
if
p
.
trace
{
defer
un
(
trace
(
p
,
"VarSpec"
))
}
...
...
@@ -1976,13 +1976,13 @@ func (p *parser) parseGenDecl(keyword token.Token, f parseSpecFunction) *ast.Gen
if
p
.
tok
==
token
.
LPAREN
{
lparen
=
p
.
pos
p
.
next
()
for
p
.
tok
!=
token
.
RPAREN
&&
p
.
tok
!=
token
.
EOF
{
list
=
append
(
list
,
f
(
p
,
p
.
leadComment
))
for
iota
:=
0
;
p
.
tok
!=
token
.
RPAREN
&&
p
.
tok
!=
token
.
EOF
;
iota
++
{
list
=
append
(
list
,
f
(
p
,
p
.
leadComment
,
iota
))
}
rparen
=
p
.
expect
(
token
.
RPAREN
)
p
.
expectSemi
()
}
else
{
list
=
append
(
list
,
f
(
p
,
nil
))
list
=
append
(
list
,
f
(
p
,
nil
,
0
))
}
return
&
ast
.
GenDecl
{
doc
,
pos
,
keyword
,
lparen
,
list
,
rparen
}
...
...
src/pkg/go/parser/parser_test.go
View file @
7664ec39
...
...
@@ -21,6 +21,7 @@ var illegalInputs = []interface{}{
`package p; func f() { if /* should have condition */ {} };`
,
`package p; func f() { if ; /* should have condition */ {} };`
,
`package p; func f() { if f(); /* should have condition */ {} };`
,
`package p; const c; /* should have constant value */`
,
}
...
...
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