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
ae5a475e
Commit
ae5a475e
authored
Dec 15, 2008
by
Ken Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
range clause must have = or :=
:= illegal in for-increment R=r OCL=21204 CL=21204
parent
7df571ae
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
15 additions
and
14 deletions
+15
-14
go.h
src/cmd/gc/go.h
+1
-0
go.y
src/cmd/gc/go.y
+5
-5
generic.go
src/lib/json/generic.go
+2
-2
generic_test.go
src/lib/json/generic_test.go
+1
-1
range.go
test/ken/range.go
+6
-6
No files found.
src/cmd/gc/go.h
View file @
ae5a475e
...
...
@@ -197,6 +197,7 @@ struct Node
uchar
method
;
// OCALLMETH name
uchar
iota
;
// OLITERAL made from iota
uchar
embedded
;
// ODCLFIELD embedded type
uchar
colas
;
// OAS resulting from :=
// most nodes
Node
*
left
;
...
...
src/cmd/gc/go.y
View file @
ae5a475e
...
...
@@ -419,6 +419,7 @@ simple_stmt:
$$
=
rev
($
1
);
$$
=
colas
($$,
$
3
);
$$
=
nod
(
OAS
,
$$,
$
3
);
$$->
colas
=
1
;
addtotop
($$);
}
|
LPRINT
'('
oexpr_list
')'
...
...
@@ -554,9 +555,6 @@ compound_stmt:
popdcl
();
}
ocolas
:
|
LCOLAS
orange_stmt
:
osimple_stmt
|
exprsym3_list_r
'='
LRANGE
expr
...
...
@@ -570,12 +568,12 @@ orange_stmt:
$$
=
nod
(
ORANGE
,
$$,
$
6
);
$$->
etype
=
0
;
}
|
exprsym3_list_r
ocolas
LRANGE
expr
|
exprsym3_list_r
LCOLAS
LRANGE
expr
{
$$
=
nod
(
ORANGE
,
$
1
,
$
4
);
$$->
etype
=
1
;
}
|
exprsym3
':'
exprsym3
ocolas
LRANGE
expr
|
exprsym3
':'
exprsym3
LCOLAS
LRANGE
expr
{
$$
=
nod
(
OLIST
,
$
1
,
$
3
);
$$
=
nod
(
ORANGE
,
$$,
$
6
);
...
...
@@ -592,6 +590,8 @@ for_header:
break
;
}
//
init
;
test
;
incr
if
($
5
!= N && $5->colas != 0)
yyerror
(
"cannot declare in the for-increment"
);
$$
=
nod
(
OFOR
,
N
,
N
);
$$->
ninit
=
$
1
;
$$->
ntest
=
$
3
;
...
...
src/lib/json/generic.go
View file @
ae5a475e
...
...
@@ -114,7 +114,7 @@ func (j *Map) Get(s string) Json {
func
(
j
*
Map
)
String
()
string
{
s
:=
"{"
;
first
:=
true
;
for
k
,
v
range
j
.
m
{
for
k
,
v
:=
range
j
.
m
{
if
first
{
first
=
false
;
}
else
{
...
...
@@ -188,7 +188,7 @@ export func Equal(a, b Json) bool {
if
len
(
m
)
!=
len
(
b
.
(
*
Map
)
.
m
)
{
return
false
;
}
for
k
,
v
range
m
{
for
k
,
v
:=
range
m
{
if
!
Equal
(
v
,
b
.
Get
(
k
))
{
return
false
;
}
...
...
src/lib/json/generic_test.go
View file @
ae5a475e
...
...
@@ -64,7 +64,7 @@ export func TestJsonMap(t *testing.T) {
if
mapv
==
nil
{
t
.
Fatalf
(
"StringToJson(%#q) => nil, %v, %v"
,
mapstr
,
ok
,
errtok
);
}
for
k
,
v
range
values
{
for
k
,
v
:=
range
values
{
if
v1
:=
mapv
.
Get
(
k
);
!
Equal
(
v1
,
v
)
{
t
.
Errorf
(
"MapTest: Walk(%#q) => %v, want %v"
,
k
,
v1
,
v
);
}
...
...
test/ken/range.go
View file @
ae5a475e
...
...
@@ -40,7 +40,7 @@ main()
* key only
*/
i
=
0
;
for
k
range
a
{
for
k
:=
range
a
{
v
:=
a
[
k
];
if
v
!=
f
(
k
)
{
panicln
(
"key array range"
,
k
,
v
,
a
[
k
]);
...
...
@@ -52,7 +52,7 @@ main()
}
i
=
0
;
for
k
range
p
{
for
k
:=
range
p
{
v
:=
p
[
k
];
if
v
!=
f
(
k
)
{
panicln
(
"key pointer range"
,
k
,
v
,
p
[
k
]);
...
...
@@ -64,7 +64,7 @@ main()
}
i
=
0
;
for
k
range
m
{
for
k
:=
range
m
{
v
:=
m
[
k
];
if
v
!=
f
(
k
)
{
panicln
(
"key map range"
,
k
,
v
,
m
[
k
]);
...
...
@@ -79,7 +79,7 @@ main()
* key:value
*/
i
=
0
;
for
k
:
v
range
a
{
for
k
:
v
:=
range
a
{
if
v
!=
f
(
k
)
{
panicln
(
"key:value array range"
,
k
,
v
,
a
[
k
]);
}
...
...
@@ -90,7 +90,7 @@ main()
}
i
=
0
;
for
k
:
v
range
p
{
for
k
:
v
:=
range
p
{
if
v
!=
f
(
k
)
{
panicln
(
"key:value pointer range"
,
k
,
v
,
p
[
k
]);
}
...
...
@@ -101,7 +101,7 @@ main()
}
i
=
0
;
for
k
:
v
range
m
{
for
k
:
v
:=
range
m
{
if
v
!=
f
(
k
)
{
panicln
(
"key:value map range"
,
k
,
v
,
m
[
k
]);
}
...
...
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