Skip to content

Commit

Permalink
Fix bug with flagging shadowed stdlib func
Browse files Browse the repository at this point in the history
  • Loading branch information
TwitchBronBron committed Nov 19, 2020
1 parent 1370414 commit 8d1cdef
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/Scope.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -297,12 +297,12 @@ describe('Scope', () => {
});
});

it('detects scope function with same name as built-in function', async () => {
it('flags scope function with same name (but different case) as built-in function', async () => {
await program.addOrReplaceFile({ src: s`${rootDir}/source/main.brs`, dest: s`source/main.brs` }, `
sub main()
print str(12345) ' prints 12345 (i.e. our str() function below is ignored)
end sub
function str(num)
function STR(num)
return "override"
end function
`);
Expand Down
2 changes: 1 addition & 1 deletion src/Scope.ts
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ export class Scope {
if (lowerFuncName) {

//find function declarations with the same name as a stdlib function
if (globalCallableMap.has(func.getName(ParseMode.BrighterScript))) {
if (globalCallableMap.has(lowerFuncName)) {
this.diagnostics.push({
...DiagnosticMessages.scopeFunctionShadowedByBuiltInFunction(),
range: func.nameRange,
Expand Down

0 comments on commit 8d1cdef

Please sign in to comment.