Skip to content
Open
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
5 changes: 5 additions & 0 deletions src/CrossScopeValidator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,11 @@ export class CrossScopeValidator {
getRequiredMap(scope: Scope) {
const map = new Map<SymbolLookupKeys, UnresolvedSymbol>();
scope.enumerateBrsFiles((file) => {
//typedef files (.d.bs) are ambient declarations only - never validated for diagnostics,
//so don't flag their own unresolved type references as missing symbols
if (file.isTypedef) {
return;
}
for (const symbol of file.requiredSymbols) {
const symbolKeysArray = this.symbolMapKeys(symbol);
for (const symbolKeys of symbolKeysArray) {
Expand Down
13 changes: 13 additions & 0 deletions src/bscPlugin/validation/ScopeValidator.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4013,6 +4013,19 @@ describe('ScopeValidator', () => {
program.validate();
expectZeroDiagnostics(program);
});

it('does not report cannot-find-name for unresolvable types referenced in .d.bs files', () => {
//simulates a .d.bs typedef whose namespace-qualified types don't actually resolve
//(e.g. produced by a buggy third-party rewrite tool), which should never produce diagnostics
program.setFile('source/util.d.bs', `
namespace SomeNamespace
function getSomething(a as SomeNamespace.ifDraw2d) as SomeNamespace.roAssociativeArray
end function
end namespace
`);
program.validate();
expectZeroDiagnostics(program);
});
});

describe('assignmentTypeMismatch', () => {
Expand Down
10 changes: 6 additions & 4 deletions src/bscPlugin/validation/ScopeValidator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ export class ScopeValidator {

//do many per-file checks for every file in this (and parent) scopes
this.event.scope.enumerateBrsFiles((file) => {
if (!isBrsFile(file)) {
if (!isBrsFile(file) || file.isTypedef) {
return;
}

Expand All @@ -168,6 +168,11 @@ export class ScopeValidator {
this.event.scope.enumerateOwnFiles((file) => {
if (isBrsFile(file)) {

//typedef files (.d.bs) are ambient declarations only - never validated for diagnostics
if (file.isTypedef) {
return;
}

if (this.event.program.diagnostics.canSkipScopeValidationForFile(file)) {
return;
}
Expand Down Expand Up @@ -276,9 +281,6 @@ export class ScopeValidator {
});
},
FunctionExpression: (func) => {
if (file.isTypedef) {
return;
}
this.addValidationKindMetric('FunctionExpression', () => {
this.validateFunctionExpressionForReturn(func);
});
Expand Down
Loading