Skip to content
Merged
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
29 changes: 29 additions & 0 deletions src/files/BrsFile.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import * as fileUrl from 'file-url';
import { isAALiteralExpression, isBlock } from '../astUtils/reflection';
import type { AALiteralExpression } from '../parser/Expression';
import { CallExpression, FunctionExpression, LiteralExpression } from '../parser/Expression';
import { Logger } from '@rokucommunity/logger';

let sinon = sinonImport.createSandbox();

Expand Down Expand Up @@ -188,6 +189,34 @@ describe('BrsFile', () => {
expectDiagnostics(program, [DiagnosticMessages.itemCannotBeUsedAsVariable('enum').message]);
});

it('does not crazy during validation with unique binary operator', () => {
//monitor the logging system, if we detect an error, this test fails
const spy = sinon.spy(Logger.prototype, 'error');
program.setFile('source/main.bs', `
namespace date
function timeElapsedInDay()
time = 1
if true then
time = getInteger()
end if
clockSeconds = getInteger() + 1
assumedMidnight = time - clockSeconds
offset = assumedMidnight - 1
end function

function getInteger()
return 1
end function
end namespace

`);
program.validate();
expectZeroDiagnostics(program);
expect(
spy.getCalls().map(x => (x.args?.[0] as string)?.toString()).filter(x => x?.includes('Error when calling plugin'))
).to.eql([]);
});

it('supports the third parameter in CreateObject', () => {
program.setFile('source/main.brs', `
sub main()
Expand Down
2 changes: 1 addition & 1 deletion src/types/ReferenceType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ export class BinaryOperatorReferenceType extends BscType {
return () => undefined;
}
} else {
resultType = binaryOpResolver(this.leftType, this.operator, this.rightType);
resultType = binaryOpResolver(this.leftType, this.operator, this.rightType) ?? DynamicType.instance;
this.cachedType = resultType;
}

Expand Down
Loading