Skip to content

Commit

Permalink
Fix crash with missing scope (#1234)
Browse files Browse the repository at this point in the history
  • Loading branch information
TwitchBronBron authored Jun 14, 2024
1 parent cacd155 commit bf0c4b7
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1217,12 +1217,15 @@ export class Util {
expressionWalker(expression);

const scope = file.program.getFirstScopeForFile(file);
const filteredVarNames = [...uniqueVarNames].filter((varName: string) => {
const varNameLower = varName.toLowerCase();
// TODO: include namespaces in this filter
return !scope.getEnumMap().has(varNameLower) &&
!scope.getConstMap().has(varNameLower);
});
let filteredVarNames = [...uniqueVarNames];
if (scope) {
filteredVarNames = filteredVarNames.filter((varName: string) => {
const varNameLower = varName.toLowerCase();
// TODO: include namespaces in this filter
return !scope.getEnumMap().has(varNameLower) &&
!scope.getConstMap().has(varNameLower);
});
}

return { expressions: expressions, varExpressions: variableExpressions, uniqueVarNames: filteredVarNames };
}
Expand Down

0 comments on commit bf0c4b7

Please sign in to comment.