Skip to content

Commit ad1782b

Browse files
committed
Address comments
1 parent 8469bd3 commit ad1782b

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

ql/src/codeql_ruby/ast/Variable.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,14 @@ class Variable extends TVariable {
5353
}
5454

5555
/** A local variable. */
56-
class LocalVariable extends Variable {
56+
class LocalVariable extends Variable, TLocalVariable {
5757
override LocalVariable::Range range;
5858

5959
final override LocalVariableAccess getAnAccess() { result.getVariable() = this }
6060
}
6161

6262
/** A global variable. */
63-
class GlobalVariable extends Variable {
63+
class GlobalVariable extends Variable, TGlobalVariable {
6464
override GlobalVariable::Range range;
6565

6666
final override GlobalVariableAccess getAnAccess() { result.getVariable() = this }

ql/src/codeql_ruby/ast/internal/Variable.qll

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,7 @@ private module Cached {
111111

112112
cached
113113
newtype TVariable =
114-
TGlobalVariable(TGlobalScope scope, string name) {
115-
name = any(Generated::GlobalVariable var).getValue()
116-
} or
114+
TGlobalVariable(string name) { name = any(Generated::GlobalVariable var).getValue() } or
117115
TLocalVariable(VariableScope scope, string name, Generated::Identifier i) {
118116
scopeDefinesParameterVariable(scope, name, i)
119117
or
@@ -223,7 +221,7 @@ module Variable {
223221
}
224222

225223
module LocalVariable {
226-
class Range extends Variable::Range {
224+
class Range extends Variable::Range, TLocalVariable {
227225
private VariableScope scope;
228226
private string name;
229227
private Generated::Identifier i;
@@ -239,17 +237,16 @@ module LocalVariable {
239237
}
240238

241239
module GlobalVariable {
242-
class Range extends Variable::Range {
243-
private VariableScope scope;
240+
class Range extends Variable::Range, TGlobalVariable {
244241
private string name;
245242

246-
Range() { this = TGlobalVariable(scope, name) }
243+
Range() { this = TGlobalVariable(name) }
247244

248245
final override string getName() { result = name }
249246

250247
final override Location getLocation() { none() }
251248

252-
final override VariableScope getDeclaringScope() { result = scope }
249+
final override VariableScope getDeclaringScope() { result = TGlobalScope() }
253250
}
254251
}
255252

0 commit comments

Comments
 (0)