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
2f816d5b
Commit
2f816d5b
authored
Feb 16, 2010
by
Robert Griesemer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't print ()'s around a range clause's expression.
Fixes #605. R=rsc CC=golang-dev
https://golang.org/cl/207108
parent
e7fc5c27
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
6 additions
and
1 deletion
+6
-1
src/pkg/go/printer/nodes.go
src/pkg/go/printer/nodes.go
+2
-1
src/pkg/go/printer/testdata/statements.golden
src/pkg/go/printer/testdata/statements.golden
+3
-0
src/pkg/go/printer/testdata/statements.input
src/pkg/go/printer/testdata/statements.input
+1
-0
No files found.
src/pkg/go/printer/nodes.go
View file @
2f816d5b
...
@@ -671,6 +671,7 @@ func (p *printer) expr1(expr ast.Expr, prec1, depth int, ctxt exprContext, multi
...
@@ -671,6 +671,7 @@ func (p *printer) expr1(expr ast.Expr, prec1, depth int, ctxt exprContext, multi
// no parenthesis needed
// no parenthesis needed
p
.
print
(
x
.
Op
)
p
.
print
(
x
.
Op
)
if
x
.
Op
==
token
.
RANGE
{
if
x
.
Op
==
token
.
RANGE
{
// TODO(gri) Remove this code if it cannot be reached.
p
.
print
(
blank
)
p
.
print
(
blank
)
}
}
p
.
expr1
(
x
.
X
,
prec
,
depth
,
0
,
multiLine
)
p
.
expr1
(
x
.
X
,
prec
,
depth
,
0
,
multiLine
)
...
@@ -1075,7 +1076,7 @@ func (p *printer) stmt(stmt ast.Stmt, multiLine *bool) {
...
@@ -1075,7 +1076,7 @@ func (p *printer) stmt(stmt ast.Stmt, multiLine *bool) {
p
.
expr
(
s
.
Value
,
multiLine
)
p
.
expr
(
s
.
Value
,
multiLine
)
}
}
p
.
print
(
blank
,
s
.
TokPos
,
s
.
Tok
,
blank
,
token
.
RANGE
,
blank
)
p
.
print
(
blank
,
s
.
TokPos
,
s
.
Tok
,
blank
,
token
.
RANGE
,
blank
)
p
.
expr
(
s
.
X
,
multiLine
)
p
.
expr
(
s
tripParens
(
s
.
X
)
,
multiLine
)
p
.
print
(
blank
)
p
.
print
(
blank
)
p
.
block
(
s
.
Body
,
1
,
true
)
p
.
block
(
s
.
Body
,
1
,
true
)
*
multiLine
=
true
*
multiLine
=
true
...
...
src/pkg/go/printer/testdata/statements.golden
View file @
2f816d5b
...
@@ -144,6 +144,9 @@ func _() {
...
@@ -144,6 +144,9 @@ func _() {
for
x
:=
range
[]
int
{}
{
for
x
:=
range
[]
int
{}
{
use
(
x
)
use
(
x
)
}
}
for
x
:=
range
[]
int
{}
{
use
(
x
)
}
//
no
parens
printed
}
}
...
...
src/pkg/go/printer/testdata/statements.input
View file @
2f816d5b
...
@@ -107,6 +107,7 @@ func _() {
...
@@ -107,6 +107,7 @@ func _() {
}
}
for
x
:=
expr
;
expr
;
expr
=
false
{
use
(
x
)
}
for
x
:=
expr
;
expr
;
expr
=
false
{
use
(
x
)
}
for
x
:=
range
[]
int
{}
{
use
(
x
)
}
for
x
:=
range
[]
int
{}
{
use
(
x
)
}
for
x
:=
range
(([]
int
{}))
{
use
(
x
)
}
//
no
parens
printed
}
}
...
...
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