diff --git a/src/Program.spec.ts b/src/Program.spec.ts index b2658a847..0ec554849 100644 --- a/src/Program.spec.ts +++ b/src/Program.spec.ts @@ -2383,6 +2383,19 @@ describe('Program', () => { expect(signatureHelp[0]?.signature).to.not.exist; }); + it('does not crash when parts is undefined', () => { + program.setFile('source/main.bs', ` + sub main() + print m.b["c"].hello?(12345) + end sub + `); + program.validate(); + expectZeroDiagnostics(program); + // 123|45 + let signatureHelp = getSignatureHelp(2, 45); + expect(signatureHelp).is.empty; + }); + describe('gets signature info for regular function call', () => { it('does not get help when on method name', () => { program.setFile('source/main.bs', ` diff --git a/src/bscPlugin/CallExpressionInfo.ts b/src/bscPlugin/CallExpressionInfo.ts index 4fbc02808..dfd50403f 100644 --- a/src/bscPlugin/CallExpressionInfo.ts +++ b/src/bscPlugin/CallExpressionInfo.ts @@ -79,9 +79,11 @@ export class CallExpressionInfo { } else { let parts = util.getAllDottedGetParts(callExpression.callee); - parts.splice(parts?.length - 1, 1); - this.dotPart = parts.map(x => x.text).join('.'); - this.namespace = this.getNamespace(); + if (parts) { + parts.splice(parts?.length - 1, 1); + this.dotPart = parts.map(x => x.text).join('.'); + this.namespace = this.getNamespace(); + } } }