Skip to content

Commit 6ae07a2

Browse files
committed
Add location for implicitly declared variables
1 parent ffdb610 commit 6ae07a2

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

go/ql/lib/semmle/go/Scopes.qll

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -158,15 +158,16 @@ class Entity extends @object {
158158
string filepath, int startline, int startcolumn, int endline, int endcolumn
159159
) {
160160
// take the location of the declaration if there is one
161-
this.getDeclaration().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
162-
or
163-
// otherwise fall back on dummy location
164-
not exists(this.getDeclaration()) and
165-
filepath = "" and
166-
startline = 0 and
167-
startcolumn = 0 and
168-
endline = 0 and
169-
endcolumn = 0
161+
if this.hasRealLocationInfo(_, _, _, _, _)
162+
then this.hasRealLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
163+
else (
164+
// otherwise fall back on dummy location
165+
filepath = "" and
166+
startline = 0 and
167+
startcolumn = 0 and
168+
endline = 0 and
169+
endcolumn = 0
170+
)
170171
}
171172
}
172173

0 commit comments

Comments
 (0)