Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions src/files/BrsFile.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1017,6 +1017,38 @@ describe('BrsFile', () => {
program.validate();
expectZeroDiagnostics(program);
});

it('treats code 1001 (cannotFindName) as also suppressing cannotFindFunction (1140) for backward compatibility', () => {
// `cannotFindFunction` (1140) was split from `cannotFindName` (1001) after v0.65.
// Users with existing `bs:disable-line 1001` comments must not have their
// suppress directives silently broken for function-call "cannot find" errors.
program.setFile('source/main.bs', `
sub main()
undefinedFunction() 'bs:disable-line 1001
end sub
`);
program.validate();
expectZeroDiagnostics(program);
});

it('treats code 1001 as suppressing cannotFindFunction at any nesting depth', () => {
// Reproduces the original report: a 5-level-deep function call whose
// bs:disable-line 1001 comment was not suppressing the error.
program.setFile('source/main.bs', `
namespace http
function request() as object
callback = sub()
if true then
response = {}
handleInterceptedScreenData(response._interceptedScreenData) 'bs:disable-line 1001
end if
end sub
end function
end namespace
`);
program.validate();
expectZeroDiagnostics(program);
});
});

describe('bs:disable / bs:enable block directives', () => {
Expand Down
9 changes: 8 additions & 1 deletion src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -842,7 +842,14 @@ export class Util {
continue;
}
//if this flag disables the code, it's suppressed
const isDisabled = flag.codes === null || (diagnosticCode !== undefined && flag.codes?.includes(diagnosticCode));
const isDisabled = flag.codes === null || (diagnosticCode !== undefined && (
flag.codes?.includes(diagnosticCode) ||
// Backward-compat: `bs:disable-line 1001` (cannotFindName) used to suppress all
// "cannot find" errors before cannotFindFunction (1140) was introduced as a
// separate diagnostic code. Keep 1001 working for function-call errors so that
// existing disable comments aren't silently broken.
(diagnosticCode === DiagnosticCodeMap.cannotFindFunction && flag.codes?.includes(DiagnosticCodeMap.cannotFindName))
));
if (isDisabled) {
return true;
}
Expand Down