Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
golang
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
golang
Commits
82e41cc5
Commit
82e41cc5
authored
Oct 15, 2008
by
Russ Cox
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
allow trailing comma in braced initialized list
R=ken OCL=17141 CL=17143
parent
5933dbda
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
3 deletions
+45
-3
go.y
src/cmd/gc/go.y
+28
-3
initcomma.go
test/initcomma.go
+17
-0
No files found.
src/cmd/gc/go.y
View file @
82e41cc5
...
@@ -60,7 +60,7 @@
...
@@ -60,7 +60,7 @@
%
type
<
node
>
interfacedcl_list_r
interfacedcl
%
type
<
node
>
interfacedcl_list_r
interfacedcl
%
type
<
node
>
structdcl_list_r
structdcl
%
type
<
node
>
structdcl_list_r
structdcl
%
type
<
node
>
fnres
Afnres
Bfnres
fnliteral
xfndcl
fndcl
fnbody
%
type
<
node
>
fnres
Afnres
Bfnres
fnliteral
xfndcl
fndcl
fnbody
%
type
<
node
>
keyexpr_list
keyval_list_r
keyval
%
type
<
node
>
keyexpr_list
braced_keyexpr_list
keyval_list_r
keyval
%
type
<
type
>
typedclname
new_type
%
type
<
type
>
typedclname
new_type
%
type
<
type
>
type
Atype
Btype
%
type
<
type
>
type
Atype
Btype
...
@@ -871,7 +871,7 @@ pexpr:
...
@@ -871,7 +871,7 @@ pexpr:
$$
=
nod
(
OCONV
,
$
3
,
N
);
$$
=
nod
(
OCONV
,
$
3
,
N
);
$$->
type
=
oldtype
($
1
);
$$->
type
=
oldtype
($
1
);
}
}
|
convtype
'{'
keyexpr_list
'}'
|
convtype
'{'
braced_
keyexpr_list
'}'
{
{
//
composite
literal
//
composite
literal
$$
=
rev
($
3
);
$$
=
rev
($
3
);
...
@@ -1598,7 +1598,32 @@ keyexpr_list:
...
@@ -1598,7 +1598,32 @@ keyexpr_list:
{
{
$$
=
rev
($
1
);
$$
=
rev
($
1
);
}
}
|
oexpr_list
|
expr_list
/*
*
have
to
spell
this
out
using
_r
lists
to
avoid
yacc
conflict
*/
braced_keyexpr_list
:
{
$$
=
N
;
}
|
keyval_list_r
{
$$
=
rev
($
1
);
}
|
keyval_list_r
','
{
$$
=
rev
($
1
);
}
|
expr_list_r
{
$$
=
rev
($
1
);
}
|
expr_list_r
','
{
$$
=
rev
($
1
);
}
/*
/*
*
the
one
compromise
of
a
*
the
one
compromise
of
a
...
...
test/initcomma.go
0 → 100644
View file @
82e41cc5
// $G $F.go && $L $F.$A && ./$A.out
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package
main
var
a
=
[]
int
{
1
,
2
,
}
var
b
=
[
5
]
int
{
}
var
c
=
[]
int
{
1
}
func
main
()
{
if
len
(
a
)
!=
2
{
panicln
(
"len a"
,
len
(
a
))
}
if
len
(
b
)
!=
5
{
panicln
(
"len b"
,
len
(
b
))
}
if
len
(
c
)
!=
1
{
panicln
(
"len a"
,
len
(
a
))
}
}
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