From a4549807fb426e3e144a47fb59617ef0056e4a3c Mon Sep 17 00:00:00 2001 From: worksofliam Date: Mon, 21 Aug 2023 15:08:17 -0400 Subject: [PATCH] Don't check for brackets when in declare or prototype (#239) --- .vscode/launch.json | 2 +- language/linter.ts | 3 +-- tests/suite/linter.js | 31 +++++++++++++++++++++++++++++++ 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index eed3ecb0..dd6fe634 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -39,7 +39,7 @@ "type": "npm", "script": "compile:tests" }, - "args": ["issue_240"], + "args": ["issue_239"], "env": { "INCLUDE_DIR": "${workspaceFolder}" } diff --git a/language/linter.ts b/language/linter.ts index c95adda7..dfca2181 100644 --- a/language/linter.ts +++ b/language/linter.ts @@ -822,8 +822,7 @@ export default class Linter { } if ((isDeclare && i >= 2) || !isDeclare) { - if (rules.RequiresParameter && !inPrototype) { - + if (rules.RequiresParameter && !inPrototype && !isDeclare) { // Check the procedure reference has a block following it const definedProcedure = globalProcs.find(proc => proc.name.toUpperCase() === upperName); if (definedProcedure) { diff --git a/tests/suite/linter.js b/tests/suite/linter.js index 4507a2b9..7213e574 100644 --- a/tests/suite/linter.js +++ b/tests/suite/linter.js @@ -3316,4 +3316,35 @@ exports.issue_240 = async () => { }); assert.strictEqual(lines.substring(errors[0].offset.position, errors[0].offset.end), `dcl-pr QCMDEXC extpgm('QCMDEXC')`); +} + +exports.issue_239 = async () => { + const lines = [ + `**FREE`, + `ctl-opt dftactgrp(*NO);`, + ``, + `// If RequiresParameter is enabled, the following line will be flagged with "Procedure calls require brackets.".`, + `dcl-s myValue like(getSomeValue);`, + ``, + `// !! The following is not valid syntax and will not compile:`, + `// !! dcl-s myValue like(getSomeValue()); // Invalid syntax; will not compile`, + ``, + `myValue = getSomeValue();`, + `*inLR = *ON;`, + `return;`, + ``, + `dcl-proc getSomeValue;`, + ` dcl-pi *N varchar(10);`, + ` end-pi;`, + ` return %char(%date(): *ISO);`, + `end-proc;`, + ].join(`\n`); + + const parser = parserSetup(); + const cache = await parser.getDocs(uri, lines); + const { errors } = Linter.getErrors({ uri, content: lines }, { + RequiresParameter: true + }, cache); + + assert.strictEqual(errors.length, 0); } \ No newline at end of file