From 54724b28c488004befba595a20e6131d6ea5e0ca Mon Sep 17 00:00:00 2001 From: Patrick Behr Date: Fri, 27 Jan 2023 17:17:14 -0800 Subject: [PATCH] On-error statement shouldn't be considered individual words --- server/src/language/statement.js | 11 +++++++++++ tests/suite/linter.js | 21 +++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/server/src/language/statement.js b/server/src/language/statement.js index 09db76f5..3631cfd6 100644 --- a/server/src/language/statement.js +++ b/server/src/language/statement.js @@ -161,6 +161,17 @@ const commonMatchers = [ becomes: { type: `builtin` } + }, + { + name: `ON-ERROR`, + match: [ + { type: `word`, match: (word) => word.toUpperCase() === `ON` }, + { type: `minus` }, + { type: `word`, match: (word) => word.toUpperCase() === `ERROR` }, + ], + becomes: { + type: `word` + } } ]; diff --git a/tests/suite/linter.js b/tests/suite/linter.js index afd25893..e8323c06 100644 --- a/tests/suite/linter.js +++ b/tests/suite/linter.js @@ -3159,6 +3159,27 @@ exports.linter40_keywordrefs = async () => { }); } +exports.linter_casing_on_error_not_a_variable = async () => { + const lines = [ + `**free`, + `dcl-c ERROR -1;`, + `monitor;`, + ` callSomething();`, + `on-error;`, + ` result = ERROR;`, + `endmon;`, + ].join(`\n`); + + const parser = parserSetup(); + const cache = await parser.getDocs(uri, lines); + const { errors } = Linter.getErrors({ uri, content: lines }, { + CollectReferences: true, + IncorrectVariableCase: true + }, cache); + + assert.strictEqual(errors.length, 0, `on-error should not throw a variable casing error`); +} + exports.issue_175 = async () => { const lines = [ `**FREE`,