@abaplint/core 2.120.60 → 2.120.61

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -643,6 +643,8 @@ export declare class BuiltIn {
643
643
  private row;
644
644
  private static buildDefinition;
645
645
  static searchBuiltin(name: string | undefined): IMethodDefinition | undefined;
646
+ private static readonly unnamedArgument;
647
+ static hasUnnamedArgument(name: string | undefined): boolean;
646
648
  static isPredicate(name: string | undefined): boolean | undefined;
647
649
  getTypes(): TypedIdentifier[];
648
650
  get(extras: string[]): TypedIdentifier[];
@@ -118,6 +118,12 @@ class BuiltIn {
118
118
  }
119
119
  return this.buildDefinition(def, name);
120
120
  }
121
+ static hasUnnamedArgument(name) {
122
+ if (name === undefined) {
123
+ return false;
124
+ }
125
+ return BuiltIn.unnamedArgument.has(name.toUpperCase());
126
+ }
121
127
  static isPredicate(name) {
122
128
  if (name === undefined) {
123
129
  return undefined;
@@ -1219,4 +1225,10 @@ BuiltIn.methods = {
1219
1225
  return: basic_1.IntegerType.get(),
1220
1226
  },
1221
1227
  };
1228
+ // functions called with exactly one unnamed argument, all others take named arguments like "val"
1229
+ BuiltIn.unnamedArgument = new Set([
1230
+ "ABS", "ACOS", "ASIN", "ATAN", "BOOLC", "CEIL", "CHARLEN", "COS", "COSH", "DBMAXLEN", "EXP", "FLOOR",
1231
+ "FRAC", "LINES", "LOG", "LOG10", "NUMOFCHAR", "SIGN", "SIN", "SINH", "SQRT", "STRLEN", "TAN", "TANH",
1232
+ "TRUNC", "XSTRLEN"
1233
+ ]);
1222
1234
  //# sourceMappingURL=_builtin.js.map
@@ -34,15 +34,52 @@ var __importStar = (this && this.__importStar) || (function () {
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.Case = void 0;
37
+ exports.checkCaseOperand = checkCaseOperand;
37
38
  const Expressions = __importStar(require("../../2_statements/expressions"));
38
39
  const source_1 = require("../expressions/source");
40
+ const _syntax_input_1 = require("../_syntax_input");
41
+ const _builtin_1 = require("../_builtin");
42
+ const _object_oriented_1 = require("../_object_oriented");
43
+ const basic_1 = require("../../types/basic");
44
+ const version_1 = require("../../../version");
39
45
  class Case {
40
46
  runSyntax(node, input) {
41
47
  // just recurse
42
48
  for (const s of node.findDirectExpressions(Expressions.Source)) {
43
49
  source_1.Source.runSyntax(s, input);
50
+ checkCaseOperand(s, input);
44
51
  }
45
52
  }
46
53
  }
47
54
  exports.Case = Case;
55
+ // Before 7.40 SP02 the operands of CASE and WHEN are enhanced functional operand positions: besides
56
+ // data objects and functional methods, only built-in functions with exactly one unnamed argument are allowed
57
+ function checkCaseOperand(source, input) {
58
+ var _a, _b;
59
+ if ((0, version_1.releaseAtLeast)(input.scope.getRelease(), version_1.Release.v740sp02)
60
+ || input.scope.getLanguageVersion() === version_1.LanguageVersion.Cloud
61
+ || input.scope.getOpenABAP()) {
62
+ return;
63
+ }
64
+ const chain = source.findDirectExpression(Expressions.MethodCallChain);
65
+ if (chain === undefined || source.getChildren().length !== 1 || chain.getChildren().length !== 1) {
66
+ return;
67
+ }
68
+ const call = chain.findDirectExpression(Expressions.MethodCall);
69
+ const nameToken = (_a = call === null || call === void 0 ? void 0 : call.findDirectExpression(Expressions.MethodName)) === null || _a === void 0 ? void 0 : _a.getFirstToken();
70
+ const name = nameToken === null || nameToken === void 0 ? void 0 : nameToken.getStr();
71
+ if (nameToken === undefined || _builtin_1.BuiltIn.searchBuiltin(name) === undefined || _builtin_1.BuiltIn.hasUnnamedArgument(name)) {
72
+ return;
73
+ }
74
+ // a method of the enclosing class takes precedence over the built-in function
75
+ const meType = (_b = input.scope.findVariable("me")) === null || _b === void 0 ? void 0 : _b.getType();
76
+ if (meType instanceof basic_1.ObjectReferenceType) {
77
+ const def = input.scope.findObjectDefinition(meType.getIdentifierName());
78
+ if (new _object_oriented_1.ObjectOriented(input.scope).searchMethodName(def, name).method !== undefined) {
79
+ return;
80
+ }
81
+ }
82
+ const message = "Built-in function " + name + " not allowed as CASE/WHEN operand before v740sp02";
83
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, nameToken, message));
84
+ }
48
85
  //# sourceMappingURL=case.js.map
@@ -36,11 +36,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.When = void 0;
37
37
  const Expressions = __importStar(require("../../2_statements/expressions"));
38
38
  const source_1 = require("../expressions/source");
39
+ const case_1 = require("./case");
39
40
  class When {
40
41
  runSyntax(node, input) {
41
42
  for (const s of node.findAllExpressions(Expressions.Source)) {
42
43
  source_1.Source.runSyntax(s, input);
43
44
  }
45
+ for (const s of node.findDirectExpressions(Expressions.Source)) {
46
+ (0, case_1.checkCaseOperand)(s, input);
47
+ }
44
48
  }
45
49
  }
46
50
  exports.When = When;
@@ -75,7 +75,7 @@ class Registry {
75
75
  }
76
76
  static abaplintVersion() {
77
77
  // magic, see build script "version.js"
78
- return "2.120.60";
78
+ return "2.120.61";
79
79
  }
80
80
  getDDICReferences() {
81
81
  return this.ddicReferences;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/core",
3
- "version": "2.120.60",
3
+ "version": "2.120.61",
4
4
  "description": "abaplint - Core API",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/abaplint.d.ts",