Skip to content

Commit

Permalink
Don't check for brackets when in declare or prototype (#239)
Browse files Browse the repository at this point in the history
  • Loading branch information
worksofliam committed Aug 21, 2023
1 parent 867d38f commit a454980
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"type": "npm",
"script": "compile:tests"
},
"args": ["issue_240"],
"args": ["issue_239"],
"env": {
"INCLUDE_DIR": "${workspaceFolder}"
}
Expand Down
3 changes: 1 addition & 2 deletions language/linter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
31 changes: 31 additions & 0 deletions tests/suite/linter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

0 comments on commit a454980

Please sign in to comment.