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
9d634e50
Commit
9d634e50
authored
Jan 07, 2011
by
Robert Griesemer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gofmt: rewriter matches apply to expressions only
Fixes #1384. R=rsc CC=golang-dev
https://golang.org/cl/3912041
parent
ee58cc79
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
6 deletions
+9
-6
src/cmd/gofmt/rewrite.go
src/cmd/gofmt/rewrite.go
+9
-6
No files found.
src/cmd/gofmt/rewrite.go
View file @
9d634e50
...
...
@@ -111,15 +111,18 @@ func match(m map[string]reflect.Value, pattern, val reflect.Value) bool {
if
m
!=
nil
&&
pattern
.
Type
()
==
identType
{
name
:=
pattern
.
Interface
()
.
(
*
ast
.
Ident
)
.
Name
if
isWildcard
(
name
)
{
if
old
,
ok
:=
m
[
name
];
ok
{
return
match
(
nil
,
old
,
val
)
// wildcards only match expressions
if
_
,
ok
:=
val
.
Interface
()
.
(
ast
.
Expr
);
ok
{
if
old
,
ok
:=
m
[
name
];
ok
{
return
match
(
nil
,
old
,
val
)
}
m
[
name
]
=
val
return
true
}
m
[
name
]
=
val
return
true
}
}
// Otherwise,
the expressions
must match recursively.
// Otherwise,
pattern and val
must match recursively.
if
pattern
==
nil
||
val
==
nil
{
return
pattern
==
nil
&&
val
==
nil
}
...
...
@@ -204,7 +207,7 @@ func subst(m map[string]reflect.Value, pattern reflect.Value, pos reflect.Value)
if
pos
!=
nil
&&
pattern
.
Type
()
==
positionType
{
// use new position only if old position was valid in the first place
if
old
:=
pattern
.
Interface
()
.
(
token
.
Pos
ition
);
!
old
.
IsValid
()
{
if
old
:=
pattern
.
Interface
()
.
(
token
.
Pos
);
!
old
.
IsValid
()
{
return
pattern
}
return
pos
...
...
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