@abaplint/core 2.120.110 → 2.120.112

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.
Files changed (41) hide show
  1. package/build/abaplint.d.ts +12 -0
  2. package/build/src/abap/2_statements/expressions/loop_group_by.js +1 -1
  3. package/build/src/abap/2_statements/statements/authority_check.js +1 -1
  4. package/build/src/abap/2_statements/statements/commit.js +1 -1
  5. package/build/src/abap/2_statements/statements/convert.js +2 -2
  6. package/build/src/abap/2_statements/statements/do.js +2 -1
  7. package/build/src/abap/2_statements/statements/exit.js +2 -1
  8. package/build/src/abap/2_statements/statements/get_time.js +3 -2
  9. package/build/src/abap/2_statements/statements/perform.js +1 -1
  10. package/build/src/abap/2_statements/statements/rollback.js +1 -1
  11. package/build/src/abap/2_statements/statements/wait.js +1 -1
  12. package/build/src/abap/5_syntax/_builtin_call.js +98 -0
  13. package/build/src/abap/5_syntax/_current_scope.js +15 -0
  14. package/build/src/abap/5_syntax/_object_oriented.js +11 -0
  15. package/build/src/abap/5_syntax/basic_types.js +30 -0
  16. package/build/src/abap/5_syntax/expressions/_substring.js +5 -4
  17. package/build/src/abap/5_syntax/expressions/compare.js +17 -31
  18. package/build/src/abap/5_syntax/expressions/cond_body.js +7 -0
  19. package/build/src/abap/5_syntax/expressions/for.js +32 -4
  20. package/build/src/abap/5_syntax/expressions/inline_loop_definition.js +8 -3
  21. package/build/src/abap/5_syntax/expressions/loop_group_by.js +123 -13
  22. package/build/src/abap/5_syntax/expressions/select.js +34 -2
  23. package/build/src/abap/5_syntax/expressions/source.js +46 -0
  24. package/build/src/abap/5_syntax/expressions/switch_body.js +6 -0
  25. package/build/src/abap/5_syntax/statements/loop.js +12 -1
  26. package/build/src/abap/5_syntax/statements/message.js +10 -0
  27. package/build/src/abap/5_syntax/statements/move.js +8 -0
  28. package/build/src/abap/5_syntax/statements/raise.js +5 -0
  29. package/build/src/abap/5_syntax/statements/write.js +10 -0
  30. package/build/src/abap/5_syntax/syntax.js +7 -0
  31. package/build/src/abap/types/event_definition.js +12 -0
  32. package/build/src/abap/types/function_module_definition.js +16 -0
  33. package/build/src/registry.js +1 -1
  34. package/build/src/rules/downport.js +5 -0
  35. package/build/src/rules/function_module_parameter_names.js +139 -0
  36. package/build/src/rules/index.js +2 -0
  37. package/build/src/rules/loop_target_misuse.js +268 -4
  38. package/build/src/rules/redundant_conversion.js +15 -3
  39. package/build/src/rules/rfc_error_handling.js +63 -13
  40. package/build/src/rules/unhandled_classic_exception.js +305 -0
  41. package/package.json +1 -1
@@ -1593,6 +1593,9 @@ export declare class CurrentScope {
1593
1593
  private readonly localFriends;
1594
1594
  /** types of the FOR and LET names used in a procedure, key is the scope node of the procedure */
1595
1595
  private readonly localNameTypes;
1596
+ /** row type of the members of a group, key is the identifier of the group variable,
1597
+ * a LOOP AT ... GROUP BY binds the group until its ENDLOOP */
1598
+ private readonly groupMemberTypes;
1596
1599
  static buildDefault(reg: IRegistry, obj: IObject): CurrentScope;
1597
1600
  private static addBuiltIn;
1598
1601
  private constructor();
@@ -1663,6 +1666,10 @@ export declare class CurrentScope {
1663
1666
  checkLocalName(name: string, type: AbstractType | undefined): string | undefined;
1664
1667
  /** types are compared by their structure, ABAP compares the declared types, so this finds a subset of the errors */
1665
1668
  private static isComparable;
1669
+ setGroupMemberType(group: TypedIdentifier, rowType: AbstractType): void;
1670
+ findGroupMemberType(group: TypedIdentifier): AbstractType | undefined;
1671
+ removeGroupMemberType(group: TypedIdentifier): void;
1672
+ private static groupKey;
1666
1673
  getEnclosingMethodName(): string | undefined;
1667
1674
  getEnclosingClassName(): string | undefined;
1668
1675
  isGlobalOO(): boolean;
@@ -3098,12 +3105,17 @@ declare class FunctionModuleDefinition {
3098
3105
  private parameters;
3099
3106
  private globalParameters;
3100
3107
  private moduleType;
3108
+ private exceptions;
3109
+ private classBasedExceptions;
3101
3110
  constructor(data: any);
3102
3111
  getParameters(): readonly IFunctionModuleParameter[];
3103
3112
  getModuleType(): FunctionModuleType | undefined;
3104
3113
  getDescription(): string | undefined;
3105
3114
  getName(): string;
3106
3115
  isGlobalParameters(): boolean;
3116
+ /** the classic exceptions, or the exception classes if isClassBasedExceptions() */
3117
+ getExceptions(): readonly string[];
3118
+ isClassBasedExceptions(): boolean;
3107
3119
  private parse;
3108
3120
  }
3109
3121
 
@@ -9,7 +9,7 @@ const loop_group_by_component_1 = require("./loop_group_by_component");
9
9
  class LoopGroupBy extends combi_1.Expression {
10
10
  getRunnable() {
11
11
  const components = (0, combi_1.seq)((0, combi_1.tok)(tokens_1.WParenLeftW), (0, combi_1.plus)(loop_group_by_component_1.LoopGroupByComponent), (0, combi_1.tok)(tokens_1.WParenRightW));
12
- const ret = (0, combi_1.seq)((0, combi_1.alt)(source_1.Source, components), (0, combi_1.optPrio)("ASCENDING"), (0, combi_1.optPrio)("WITHOUT MEMBERS"), loop_group_by_target_1.LoopGroupByTarget);
12
+ const ret = (0, combi_1.seq)((0, combi_1.alt)(source_1.Source, components), (0, combi_1.optPrio)((0, combi_1.seq)((0, combi_1.alt)("ASCENDING", "DESCENDING"), (0, combi_1.optPrio)("AS TEXT"))), (0, combi_1.optPrio)("WITHOUT MEMBERS"), loop_group_by_target_1.LoopGroupByTarget);
13
13
  return ret;
14
14
  }
15
15
  }
@@ -8,7 +8,7 @@ class AuthorityCheck {
8
8
  getMatcher() {
9
9
  const field = (0, combi_1.seq)("FIELD", expressions_1.Source);
10
10
  const id = (0, combi_1.seq)("ID", expressions_1.Source, (0, combi_1.alt)(field, "DUMMY"));
11
- const ret = (0, combi_1.seq)("AUTHORITY-CHECK OBJECT", expressions_1.Source, (0, combi_1.opt)((0, combi_1.seq)("FOR USER", expressions_1.Source)), (0, combi_1.plus)(id));
11
+ const ret = (0, combi_1.seq)("AUTHORITY-CHECK OBJECT", expressions_1.Source, (0, combi_1.opt)((0, combi_1.verNotLang)(version_1.LanguageVersion.Cloud, (0, combi_1.seq)("FOR USER", expressions_1.Source))), (0, combi_1.plus)(id));
12
12
  return (0, combi_1.verNotLang)(version_1.LanguageVersion.KeyUser, ret);
13
13
  }
14
14
  }
@@ -7,7 +7,7 @@ const version_1 = require("../../../version");
7
7
  class Commit {
8
8
  getMatcher() {
9
9
  const work = (0, combi_1.seq)("WORK", (0, combi_1.opt)("AND WAIT"));
10
- return (0, combi_1.verNotLang)(version_1.LanguageVersion.KeyUser, (0, combi_1.seq)("COMMIT", (0, combi_1.alt)(work, expressions_1.DatabaseConnection)));
10
+ return (0, combi_1.verNotLang)(version_1.LanguageVersion.KeyUser, (0, combi_1.seq)("COMMIT", (0, combi_1.alt)(work, (0, combi_1.verNotLang)(version_1.LanguageVersion.Cloud, expressions_1.DatabaseConnection))));
11
11
  }
12
12
  }
13
13
  exports.Commit = Commit;
@@ -17,9 +17,9 @@ class Convert {
17
17
  const tim = (0, combi_1.seq)("TIME", expressions_1.Source);
18
18
  const stamp = (0, combi_1.seq)("INTO TIME STAMP", expressions_1.Target);
19
19
  const intoutc = (0, combi_1.ver)(version_1.Release.v754, (0, combi_1.seq)("INTO UTCLONG", expressions_1.Target), { also: combi_1.AlsoIn.OpenABAP });
20
- const invert = (0, combi_1.seq)("INTO INVERTED-DATE", expressions_1.Target);
20
+ const invert = (0, combi_1.verNotLang)(version_1.LanguageVersion.Cloud, (0, combi_1.seq)("INTO INVERTED-DATE", expressions_1.Target));
21
21
  const date = (0, combi_1.seq)((0, combi_1.per)(dat, tim), (0, combi_1.per)(daylightSource, stamp, zone, invert, intoutc));
22
- const inv = (0, combi_1.seq)("INVERTED-DATE", expressions_1.Source, "INTO DATE", expressions_1.Target);
22
+ const inv = (0, combi_1.verNotLang)(version_1.LanguageVersion.Cloud, (0, combi_1.seq)("INVERTED-DATE", expressions_1.Source, "INTO DATE", expressions_1.Target));
23
23
  const utclong = (0, combi_1.ver)(version_1.Release.v754, (0, combi_1.seq)("UTCLONG", expressions_1.Source, (0, combi_1.per)(zone, into, daylightTarget)), { also: combi_1.AlsoIn.OpenABAP });
24
24
  return (0, combi_1.seq)("CONVERT", (0, combi_1.alt)(time, date, inv, utclong));
25
25
  }
@@ -2,13 +2,14 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Do = void 0;
4
4
  const combi_1 = require("../combi");
5
+ const version_1 = require("../../../version");
5
6
  const expressions_1 = require("../expressions");
6
7
  class Do {
7
8
  getMatcher() {
8
9
  const range = (0, combi_1.seq)("RANGE", expressions_1.Source);
9
10
  const vary = (0, combi_1.seq)("VARYING", expressions_1.Target, "FROM", expressions_1.Source, "NEXT", expressions_1.Source, (0, combi_1.optPrio)(range));
10
11
  const times = (0, combi_1.seq)(expressions_1.Source, "TIMES");
11
- return (0, combi_1.seq)("DO", (0, combi_1.optPrio)((0, combi_1.per)((0, combi_1.plus)(vary), times)));
12
+ return (0, combi_1.seq)("DO", (0, combi_1.optPrio)((0, combi_1.per)((0, combi_1.verNotLang)(version_1.LanguageVersion.Cloud, (0, combi_1.plus)(vary)), times)));
12
13
  }
13
14
  }
14
15
  exports.Do = Do;
@@ -2,9 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Exit = void 0;
4
4
  const combi_1 = require("../combi");
5
+ const version_1 = require("../../../version");
5
6
  class Exit {
6
7
  getMatcher() {
7
- return (0, combi_1.seq)("EXIT", (0, combi_1.opt)((0, combi_1.alt)("FROM SQL", "FROM STEP-LOOP")));
8
+ return (0, combi_1.seq)("EXIT", (0, combi_1.opt)((0, combi_1.verNotLang)(version_1.LanguageVersion.Cloud, (0, combi_1.alt)("FROM SQL", "FROM STEP-LOOP"))));
8
9
  }
9
10
  }
10
11
  exports.Exit = Exit;
@@ -6,8 +6,9 @@ const expressions_1 = require("../expressions");
6
6
  const version_1 = require("../../../version");
7
7
  class GetTime {
8
8
  getMatcher() {
9
- const options = (0, combi_1.seq)((0, combi_1.alt)("STAMP FIELD", "FIELD"), expressions_1.Target);
10
- return (0, combi_1.verNotLang)(version_1.LanguageVersion.KeyUser, (0, combi_1.seq)("GET TIME", (0, combi_1.opt)(options)));
9
+ const stamp = (0, combi_1.seq)("GET TIME STAMP FIELD", expressions_1.Target);
10
+ const time = (0, combi_1.verNotLang)(version_1.LanguageVersion.Cloud, (0, combi_1.seq)("GET TIME", (0, combi_1.opt)((0, combi_1.seq)("FIELD", expressions_1.Target))));
11
+ return (0, combi_1.verNotLang)(version_1.LanguageVersion.KeyUser, (0, combi_1.alt)(stamp, time));
11
12
  }
12
13
  }
13
14
  exports.GetTime = GetTime;
@@ -42,7 +42,7 @@ const expressions_1 = require("../expressions");
42
42
  class Perform {
43
43
  getMatcher() {
44
44
  const level = (0, combi_1.seq)("LEVEL", Expressions.Source);
45
- const commit = (0, combi_1.alt)((0, combi_1.seq)("ON COMMIT", (0, combi_1.opt)(level)), "ON ROLLBACK");
45
+ const commit = (0, combi_1.verNotLang)(version_1.LanguageVersion.Cloud, (0, combi_1.alt)((0, combi_1.seq)("ON COMMIT", (0, combi_1.opt)(level)), "ON ROLLBACK"));
46
46
  const short = (0, combi_1.verNotLang)(version_1.LanguageVersion.Cloud, (0, combi_1.seq)(Expressions.FormName, (0, combi_1.tok)(tokens_1.ParenLeft), Expressions.IncludeName, (0, combi_1.tok)(tokens_1.ParenRightW)));
47
47
  const program = (0, combi_1.seq)("IN PROGRAM", (0, combi_1.opt)((0, combi_1.alt)(Expressions.Dynamic, Expressions.IncludeName)));
48
48
  const found = (0, combi_1.str)("IF FOUND");
@@ -6,7 +6,7 @@ const expressions_1 = require("../expressions");
6
6
  const version_1 = require("../../../version");
7
7
  class Rollback {
8
8
  getMatcher() {
9
- return (0, combi_1.verNotLang)(version_1.LanguageVersion.KeyUser, (0, combi_1.seq)("ROLLBACK", (0, combi_1.altPrio)("WORK", expressions_1.DatabaseConnection)));
9
+ return (0, combi_1.verNotLang)(version_1.LanguageVersion.KeyUser, (0, combi_1.seq)("ROLLBACK", (0, combi_1.altPrio)("WORK", (0, combi_1.verNotLang)(version_1.LanguageVersion.Cloud, expressions_1.DatabaseConnection))));
10
10
  }
11
11
  }
12
12
  exports.Rollback = Rollback;
@@ -14,7 +14,7 @@ class Wait {
14
14
  const type = (0, combi_1.seq)("FOR", (0, combi_1.per)(channels, push, tasks));
15
15
  const until = (0, combi_1.seq)((0, combi_1.opt)(type), "UNTIL", expressions_1.Cond, (0, combi_1.opt)(up));
16
16
  const ret = (0, combi_1.seq)("WAIT", (0, combi_1.alt)(until, up));
17
- return (0, combi_1.verNotLang)(version_1.LanguageVersion.KeyUser, ret);
17
+ return (0, combi_1.verNotLang)(version_1.LanguageVersion.Cloud, ret);
18
18
  }
19
19
  }
20
20
  exports.Wait = Wait;
@@ -0,0 +1,98 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.BuiltInCall = void 0;
37
+ const Expressions = __importStar(require("../2_statements/expressions"));
38
+ const nodes_1 = require("../nodes");
39
+ const _builtin_1 = require("./_builtin");
40
+ const _object_oriented_1 = require("./_object_oriented");
41
+ const basic_1 = require("../types/basic");
42
+ class BuiltInCall {
43
+ // the call of a built-in function that starts a method call chain, not hidden by a method of the same name
44
+ static fromChain(chain, input) {
45
+ if (chain === undefined || !(chain.get() instanceof Expressions.MethodCallChain)) {
46
+ return undefined;
47
+ }
48
+ const call = chain.getChildren()[0];
49
+ if (!(call instanceof nodes_1.ExpressionNode) || !(call.get() instanceof Expressions.MethodCall)) {
50
+ return undefined;
51
+ }
52
+ const name = this.callName(call);
53
+ // upper case, the definition is cached with the name it is first searched with
54
+ if (name === undefined || _builtin_1.BuiltIn.searchBuiltin(name.toUpperCase()) === undefined) {
55
+ return undefined;
56
+ }
57
+ const enclosing = input.scope.findClassDefinition(input.scope.getEnclosingClassName());
58
+ if (enclosing !== undefined && new _object_oriented_1.ObjectOriented(input.scope).searchMethodName(enclosing, name).method !== undefined) {
59
+ return undefined;
60
+ }
61
+ return call;
62
+ }
63
+ // the call of a built-in function when the source is exactly that one call
64
+ static fromSource(source, input) {
65
+ const chain = source === null || source === void 0 ? void 0 : source.getChildren();
66
+ if ((chain === null || chain === void 0 ? void 0 : chain.length) !== 1 || !(chain[0] instanceof nodes_1.ExpressionNode) || chain[0].getChildren().length !== 1) {
67
+ return undefined;
68
+ }
69
+ return this.fromChain(chain[0], input);
70
+ }
71
+ static callName(call) {
72
+ var _a;
73
+ return (_a = call.findDirectExpression(Expressions.MethodName)) === null || _a === void 0 ? void 0 : _a.concatTokens();
74
+ }
75
+ static isNumeric(call) {
76
+ var _a, _b, _c;
77
+ const returning = (_c = (_b = _builtin_1.BuiltIn.searchBuiltin((_a = this.callName(call)) === null || _a === void 0 ? void 0 : _a.toUpperCase())) === null || _b === void 0 ? void 0 : _b.getParameters().getReturning()) === null || _c === void 0 ? void 0 : _c.getType();
78
+ return returning instanceof basic_1.IntegerType || returning instanceof basic_1.FloatType || returning instanceof basic_1.DecFloat34Type;
79
+ }
80
+ // the call has a single argument, without a parameter name, that is a data object and not an expression
81
+ static hasDataObjectArgument(call) {
82
+ var _a;
83
+ const argument = (_a = call.findDirectExpression(Expressions.MethodCallParam)) === null || _a === void 0 ? void 0 : _a.findDirectExpression(Expressions.Source);
84
+ const children = (argument === null || argument === void 0 ? void 0 : argument.getChildren()) || [];
85
+ // a literal or a text symbol, text-001
86
+ if (children.length === 1
87
+ && (children[0].get() instanceof Expressions.Constant || children[0].get() instanceof Expressions.TextElement)) {
88
+ return true;
89
+ }
90
+ // a field, a component, an offset/length or a dereference, r->*
91
+ return children.length > 0
92
+ && children[0].get() instanceof Expressions.FieldChain
93
+ && children.every(c => c.get() instanceof Expressions.FieldChain || c.get() instanceof Expressions.Dereference)
94
+ && (argument === null || argument === void 0 ? void 0 : argument.findFirstExpression(Expressions.TableExpression)) === undefined;
95
+ }
96
+ }
97
+ exports.BuiltInCall = BuiltInCall;
98
+ //# sourceMappingURL=_builtin_call.js.map
@@ -35,6 +35,9 @@ class CurrentScope {
35
35
  this.localFriends = new Map();
36
36
  /** types of the FOR and LET names used in a procedure, key is the scope node of the procedure */
37
37
  this.localNameTypes = new WeakMap();
38
+ /** row type of the members of a group, key is the identifier of the group variable,
39
+ * a LOOP AT ... GROUP BY binds the group until its ENDLOOP */
40
+ this.groupMemberTypes = new Map();
38
41
  this.current = undefined;
39
42
  this.parentObj = obj;
40
43
  this.reg = reg;
@@ -567,6 +570,18 @@ class CurrentScope {
567
570
  && type.isGeneric() === false
568
571
  && type.toText(0).includes("Unknown type") === false;
569
572
  }
573
+ setGroupMemberType(group, rowType) {
574
+ this.groupMemberTypes.set(CurrentScope.groupKey(group), rowType);
575
+ }
576
+ findGroupMemberType(group) {
577
+ return this.groupMemberTypes.get(CurrentScope.groupKey(group));
578
+ }
579
+ removeGroupMemberType(group) {
580
+ this.groupMemberTypes.delete(CurrentScope.groupKey(group));
581
+ }
582
+ static groupKey(group) {
583
+ return group.getFilename() + ":" + group.getStart().getRow() + ":" + group.getStart().getCol();
584
+ }
570
585
  getEnclosingMethodName() {
571
586
  let curr = this.current;
572
587
  while (curr !== undefined) {
@@ -241,6 +241,17 @@ class ObjectOriented {
241
241
  }
242
242
  return undefined;
243
243
  }
244
+ // RAISE EXCEPTION and THROW are not allowed in a method whose interface declares classic EXCEPTIONS,
245
+ // not even for a CX_NO_CHECK class
246
+ checkClassBasedException() {
247
+ var _a;
248
+ const methodName = this.scope.getEnclosingMethodName();
249
+ const classDef = this.scope.findClassDefinition(this.scope.getEnclosingClassName());
250
+ if (methodName && classDef && ((_a = this.searchMethodName(classDef, methodName).method) === null || _a === void 0 ? void 0 : _a.getExceptions().length)) {
251
+ return "Old exceptions and class-based exceptions cannot be used at the same time";
252
+ }
253
+ return undefined;
254
+ }
244
255
  // SUPER-> can only call the previous implementation of the method it is used in, returns the message otherwise
245
256
  // both names are resolved in the super class, so an alias and the method it stands for are the same
246
257
  checkSuperCall(superDef, methodName) {
@@ -544,6 +544,11 @@ class BasicTypes {
544
544
  if (text === undefined) {
545
545
  text = "TYPE";
546
546
  }
547
+ const additionIssue = this.checkLengthDecimals(node, text);
548
+ if (additionIssue !== undefined) {
549
+ this.input.issues.push(additionIssue);
550
+ return basic_1.VoidType.get(_syntax_input_1.CheckSyntaxKey);
551
+ }
547
552
  let found = undefined;
548
553
  if (this.isRAPTypeStructure(text)) {
549
554
  return Types.VoidType.get((_f = node.findFirstExpression(Expressions.TypeStructure)) === null || _f === void 0 ? void 0 : _f.concatTokens());
@@ -1087,6 +1092,31 @@ class BasicTypes {
1087
1092
  }
1088
1093
  throw new Error("findValue, unexpected");
1089
1094
  }
1095
+ // the LENGTH and DECIMALS additions of DATA, TYPES, CONSTANTS and STATICS, as a system checks them:
1096
+ // LENGTH only with TYPE c, n, x or p, DECIMALS only with TYPE p, also not without a TYPE addition,
1097
+ // a named type cannot be given a length either. With LIKE, a system ignores LENGTH and rejects DECIMALS
1098
+ checkLengthDecimals(node, text) {
1099
+ const length = node.findDirectExpression(Expressions.Length);
1100
+ const decimals = node.findDirectExpression(Expressions.Decimals);
1101
+ if (length === undefined && decimals === undefined) {
1102
+ return undefined;
1103
+ }
1104
+ else if (text.startsWith("LIKE")) {
1105
+ if (decimals === undefined) {
1106
+ return undefined;
1107
+ }
1108
+ const message = "When referencing another field (with LIKE), type and length cannot be changed";
1109
+ return (0, _syntax_input_1.syntaxIssue)(this.input, decimals.getFirstToken(), message);
1110
+ }
1111
+ const builtin = text.startsWith("TYPE") ? text.substring(4).trim() : "";
1112
+ if (length !== undefined && ["C", "N", "X", "P"].includes(builtin) === false) {
1113
+ return (0, _syntax_input_1.syntaxIssue)(this.input, length.getFirstToken(), "\"LENGTH\" can only be specified for types C, N, X, or P");
1114
+ }
1115
+ else if (decimals !== undefined && builtin !== "P") {
1116
+ return (0, _syntax_input_1.syntaxIssue)(this.input, decimals.getFirstToken(), "\"DECIMALS\" can be specified only for type P");
1117
+ }
1118
+ return undefined;
1119
+ }
1090
1120
  findDecimals(node) {
1091
1121
  var _a, _b, _c;
1092
1122
  const dec = (_b = (_a = node.findDirectExpression(Expressions.Decimals)) === null || _a === void 0 ? void 0 : _a.findDirectExpression(Expressions.Integer)) === null || _b === void 0 ? void 0 : _b.concatTokens();
@@ -52,7 +52,7 @@ function substringType(context, offset, length, node, input) {
52
52
  return context;
53
53
  }
54
54
  else if (numericName !== undefined) {
55
- const message = `Offset or length specification not possible on a field of numeric type "${numericName}"`;
55
+ const message = `Field type "${numericName}" does not permit substrings to be accessed`;
56
56
  input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
57
57
  return basic_1.VoidType.get(_syntax_input_1.CheckSyntaxKey);
58
58
  }
@@ -81,12 +81,13 @@ function substringType(context, offset, length, node, input) {
81
81
  }
82
82
  return context;
83
83
  }
84
+ // the internal type code the ABAP syntax check names: I, 8, P, F, a (decfloat16), e (decfloat34)
84
85
  function numericTypeName(context) {
85
86
  if (context instanceof basic_1.IntegerType) {
86
87
  return "I";
87
88
  }
88
89
  else if (context instanceof basic_1.Integer8Type) {
89
- return "INT8";
90
+ return "8";
90
91
  }
91
92
  else if (context instanceof basic_1.PackedType) {
92
93
  return "P";
@@ -95,10 +96,10 @@ function numericTypeName(context) {
95
96
  return "F";
96
97
  }
97
98
  else if (context instanceof basic_1.DecFloat16Type) {
98
- return "DECFLOAT16";
99
+ return "a";
99
100
  }
100
101
  else if (context instanceof basic_1.DecFloat34Type) {
101
- return "DECFLOAT34";
102
+ return "e";
102
103
  }
103
104
  else if (context instanceof basic_1.DecFloatType) {
104
105
  return "DECFLOAT";
@@ -43,12 +43,20 @@ const _syntax_input_1 = require("../_syntax_input");
43
43
  const basic_1 = require("../../types/basic");
44
44
  const _type_utils_1 = require("../_type_utils");
45
45
  const _builtin_1 = require("../_builtin");
46
- const _object_oriented_1 = require("../_object_oriented");
46
+ const _builtin_call_1 = require("../_builtin_call");
47
47
  class Compare {
48
48
  static runSyntax(node, input) {
49
49
  var _a;
50
- const sourceTypes = [];
51
50
  const sources = node.findDirectExpressions(Expressions.Source);
51
+ // reported before the operands are checked, which then skip the more general predicate function message
52
+ const initialMessage = this.checkInitialOperand(node, input);
53
+ const predicateMessage = this.checkPredicateOperand(sources, input);
54
+ const operandMessage = initialMessage !== null && initialMessage !== void 0 ? initialMessage : predicateMessage;
55
+ if (operandMessage !== undefined) {
56
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), operandMessage));
57
+ }
58
+ // the operands are always checked, for their own errors and references
59
+ const sourceTypes = [];
52
60
  for (const t of sources) {
53
61
  sourceTypes.push(source_1.Source.runSyntax(t, input));
54
62
  }
@@ -58,14 +66,7 @@ class Compare {
58
66
  for (const t of node.findDirectExpressions(Expressions.MethodCallChain)) {
59
67
  method_call_chain_1.MethodCallChain.runSyntax(t, input);
60
68
  }
61
- const initialMessage = this.checkInitialOperand(node, input);
62
- if (initialMessage !== undefined) {
63
- input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), initialMessage));
64
- return;
65
- }
66
- const predicateMessage = this.checkPredicateOperand(sources, input);
67
- if (predicateMessage !== undefined) {
68
- input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), predicateMessage));
69
+ if (operandMessage !== undefined) {
69
70
  return;
70
71
  }
71
72
  const typeUtils = new _type_utils_1.TypeUtils(input.scope);
@@ -121,35 +122,20 @@ class Compare {
121
122
  if (input.scope.getOpenABAP()) {
122
123
  return undefined;
123
124
  }
125
+ let message = undefined;
124
126
  for (const source of sources) {
125
127
  const name = this.builtinCallName(source, input);
126
128
  if (_builtin_1.BuiltIn.isPredicate(name) === true) {
127
- return `Predicate function "${name}" cannot be the operand of a comparison`;
129
+ source_1.Source.predicateReported(source);
130
+ message = message !== null && message !== void 0 ? message : `Predicate function "${name}" cannot be the operand of a comparison`;
128
131
  }
129
132
  }
130
- return undefined;
133
+ return message;
131
134
  }
132
135
  // the name of the built-in function when the source is exactly one call of it, not hidden by a method of the same name
133
136
  static builtinCallName(source, input) {
134
- var _a;
135
- const chain = source === null || source === void 0 ? void 0 : source.getChildren();
136
- if ((chain === null || chain === void 0 ? void 0 : chain.length) !== 1 || !(chain[0] instanceof nodes_1.ExpressionNode) || !(chain[0].get() instanceof Expressions.MethodCallChain)) {
137
- return undefined;
138
- }
139
- const calls = chain[0].getChildren();
140
- if (calls.length !== 1 || !(calls[0] instanceof nodes_1.ExpressionNode) || !(calls[0].get() instanceof Expressions.MethodCall)) {
141
- return undefined;
142
- }
143
- const name = (_a = calls[0].findDirectExpression(Expressions.MethodName)) === null || _a === void 0 ? void 0 : _a.concatTokens();
144
- if (name === undefined || _builtin_1.BuiltIn.searchBuiltin(name) === undefined) {
145
- return undefined;
146
- }
147
- // a method of the same name hides the built-in function
148
- const enclosing = input.scope.findClassDefinition(input.scope.getEnclosingClassName());
149
- if (enclosing !== undefined && new _object_oriented_1.ObjectOriented(input.scope).searchMethodName(enclosing, name).method !== undefined) {
150
- return undefined;
151
- }
152
- return name;
137
+ const call = _builtin_call_1.BuiltInCall.fromSource(source, input);
138
+ return call === undefined ? undefined : _builtin_call_1.BuiltInCall.callName(call);
153
139
  }
154
140
  }
155
141
  exports.Compare = Compare;
@@ -35,15 +35,22 @@ var __importStar = (this && this.__importStar) || (function () {
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.CondBody = void 0;
37
37
  const Expressions = __importStar(require("../../2_statements/expressions"));
38
+ const _object_oriented_1 = require("../_object_oriented");
38
39
  const source_1 = require("./source");
39
40
  const let_1 = require("./let");
40
41
  const cond_1 = require("./cond");
41
42
  const _raise_message_1 = require("../_raise_message");
43
+ const _syntax_input_1 = require("../_syntax_input");
42
44
  class CondBody {
43
45
  static runSyntax(node, input, targetType) {
44
46
  if (node === undefined) {
45
47
  return undefined;
46
48
  }
49
+ const throwNode = node.findDirectExpression(Expressions.Throw);
50
+ const throwMessage = throwNode ? new _object_oriented_1.ObjectOriented(input.scope).checkClassBasedException() : undefined;
51
+ if (throwNode && throwMessage) {
52
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, throwNode.getFirstToken(), throwMessage));
53
+ }
47
54
  let scoped = false;
48
55
  const l = node.findDirectExpression(Expressions.Let);
49
56
  if (l) {
@@ -42,6 +42,7 @@ const _scope_type_1 = require("../_scope_type");
42
42
  const component_cond_1 = require("./component_cond");
43
43
  const cond_1 = require("./cond");
44
44
  const basic_1 = require("../../types/basic");
45
+ const loop_group_by_1 = require("./loop_group_by");
45
46
  const _typed_identifier_1 = require("../../types/_typed_identifier");
46
47
  const _reference_1 = require("../_reference");
47
48
  const let_1 = require("./let");
@@ -69,18 +70,19 @@ class For {
69
70
  for (const f of inlineField) {
70
71
  inline_field_definition_1.InlineFieldDefinition.runSyntax(f, input);
71
72
  }
73
+ let groupsSource = undefined;
72
74
  if (groupsToken !== undefined) {
73
75
  const message = input.scope.checkLocalName(groupsToken.getStr(), undefined);
74
76
  if (message !== undefined) {
75
77
  input.issues.push((0, _syntax_input_1.syntaxIssue)(input, groupsToken, message));
76
78
  return scoped;
77
79
  }
78
- const type = basic_1.VoidType.get("todoGroupBy");
79
- const identifier = new _typed_identifier_1.TypedIdentifier(groupsToken, input.filename, type, ["inline" /* IdentifierMeta.InlineDefinition */]);
80
- input.scope.addIdentifier(identifier);
81
- input.scope.addReference(groupsToken, identifier, _reference_1.ReferenceType.DataWriteReference, input.filename);
80
+ groupsSource = this.runGroups(node, groupsToken, input);
82
81
  }
83
82
  for (const s of node.findDirectExpressions(Expressions.Source)) {
83
+ if (s === groupsSource) {
84
+ continue;
85
+ }
84
86
  source_1.Source.runSyntax(s, input);
85
87
  }
86
88
  for (const s of node.findDirectExpressions(Expressions.ComponentCond)) {
@@ -94,6 +96,32 @@ class For {
94
96
  }
95
97
  return scoped;
96
98
  }
99
+ /** FOR GROUPS group OF wa IN itab GROUP BY key, returns the itab source */
100
+ static runGroups(node, groupsToken, input) {
101
+ var _a;
102
+ const tableSource = node.findExpressionAfterToken("IN");
103
+ let rowType = basic_1.VoidType.get("ForGroups");
104
+ if ((tableSource === null || tableSource === void 0 ? void 0 : tableSource.get()) instanceof Expressions.Source) {
105
+ const tableType = source_1.Source.runSyntax(tableSource, input);
106
+ if (tableType instanceof basic_1.TableType) {
107
+ rowType = tableType.getRowType();
108
+ }
109
+ }
110
+ const waToken = (_a = node.findExpressionAfterToken("OF")) === null || _a === void 0 ? void 0 : _a.getFirstToken();
111
+ if (waToken !== undefined) {
112
+ const wa = new _typed_identifier_1.TypedIdentifier(waToken, input.filename, rowType, ["inline" /* IdentifierMeta.InlineDefinition */]);
113
+ input.scope.addIdentifier(wa);
114
+ input.scope.addReference(waToken, wa, _reference_1.ReferenceType.DataWriteReference, input.filename);
115
+ }
116
+ const keyType = node.findDirectTokenByText("BY") !== undefined
117
+ ? loop_group_by_1.LoopGroupBy.runKey(node, input)
118
+ : basic_1.VoidType.get("ForGroups");
119
+ const group = new _typed_identifier_1.TypedIdentifier(groupsToken, input.filename, keyType, ["inline" /* IdentifierMeta.InlineDefinition */]);
120
+ input.scope.addIdentifier(group);
121
+ input.scope.addReference(groupsToken, group, _reference_1.ReferenceType.DataWriteReference, input.filename);
122
+ input.scope.setGroupMemberType(group, rowType);
123
+ return (tableSource === null || tableSource === void 0 ? void 0 : tableSource.get()) instanceof Expressions.Source ? tableSource : undefined;
124
+ }
97
125
  }
98
126
  exports.For = For;
99
127
  //# sourceMappingURL=for.js.map
@@ -40,6 +40,7 @@ const basic_1 = require("../../types/basic");
40
40
  const _typed_identifier_1 = require("../../types/_typed_identifier");
41
41
  const _reference_1 = require("../_reference");
42
42
  const _syntax_input_1 = require("../_syntax_input");
43
+ const loop_group_by_1 = require("./loop_group_by");
43
44
  class InlineLoopDefinition {
44
45
  static runSyntax(node, input) {
45
46
  if (node === undefined) {
@@ -52,8 +53,12 @@ class InlineLoopDefinition {
52
53
  const source = node.findDirectExpression(Expressions.Source);
53
54
  if (source && target) {
54
55
  const sourceType = source_1.Source.runSyntax(source, input);
55
- let rowType = undefined;
56
- if (sourceType instanceof basic_1.TableType) {
56
+ const inGroup = node.concatTokens().toUpperCase().includes(" IN GROUP ");
57
+ let rowType = inGroup ? loop_group_by_1.LoopGroupBy.findMemberType(source, input) : undefined;
58
+ if (rowType !== undefined) {
59
+ // FOR ... IN GROUP, the members have the row type of the grouped table
60
+ }
61
+ else if (sourceType instanceof basic_1.TableType) {
57
62
  rowType = sourceType.getRowType();
58
63
  }
59
64
  else if (sourceType instanceof basic_1.VoidType) {
@@ -65,7 +70,7 @@ class InlineLoopDefinition {
65
70
  return;
66
71
  }
67
72
  if (rowType === undefined
68
- && node.concatTokens().toUpperCase().includes(" IN GROUP ")
73
+ && inGroup
69
74
  && sourceType !== undefined) {
70
75
  rowType = sourceType;
71
76
  }