@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
@@ -35,34 +35,144 @@ var __importStar = (this && this.__importStar) || (function () {
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.LoopGroupBy = void 0;
37
37
  const Expressions = __importStar(require("../../2_statements/expressions"));
38
+ const nodes_1 = require("../../nodes");
38
39
  const basic_1 = require("../../types/basic");
39
- const component_compare_1 = require("./component_compare");
40
+ const _reference_1 = require("../_reference");
40
41
  const inline_data_1 = require("./inline_data");
41
42
  const fstarget_1 = require("./fstarget");
42
43
  const target_1 = require("./target");
43
44
  const source_1 = require("./source");
45
+ const field_chain_1 = require("./field_chain");
44
46
  class LoopGroupBy {
45
- static runSyntax(node, input) {
46
- for (const t of node.findAllExpressions(Expressions.Target)) {
47
- const inline = t.findDirectExpression(Expressions.InlineData);
47
+ /**
48
+ * @param rowType row type of the grouped table, the type of the members of each group
49
+ * @param representative the row target of the LOOP, it is the group when GROUP BY has no target
50
+ */
51
+ static runSyntax(node, input, rowType, representative) {
52
+ var _a;
53
+ const keyType = this.runKey(node, input);
54
+ const groupTarget = node.findDirectExpression(Expressions.LoopGroupByTarget);
55
+ const target = groupTarget === null || groupTarget === void 0 ? void 0 : groupTarget.findDirectExpression(Expressions.Target);
56
+ const fsTarget = groupTarget === null || groupTarget === void 0 ? void 0 : groupTarget.findDirectExpression(Expressions.FSTarget);
57
+ if (target) {
58
+ const inline = target.findDirectExpression(Expressions.InlineData);
48
59
  if (inline) {
49
- inline_data_1.InlineData.runSyntax(inline, input, basic_1.VoidType.get("todoGroupBy"));
60
+ const isReference = (groupTarget === null || groupTarget === void 0 ? void 0 : groupTarget.findDirectTokenByText("REFERENCE")) !== undefined;
61
+ inline_data_1.InlineData.runSyntax(inline, input, isReference ? new basic_1.DataReference(keyType) : keyType);
50
62
  }
51
63
  else {
52
- target_1.Target.runSyntax(t, input);
64
+ target_1.Target.runSyntax(target, input);
53
65
  }
54
66
  }
55
- for (const t of node.findAllExpressions(Expressions.FSTarget)) {
56
- fstarget_1.FSTarget.runSyntax(t, input, basic_1.VoidType.get("todoGroupBy"));
67
+ else if (fsTarget) {
68
+ fstarget_1.FSTarget.runSyntax(fsTarget, input, keyType);
57
69
  }
58
- for (const t of node.findDirectExpressions(Expressions.Source)) {
59
- source_1.Source.runSyntax(t, input, basic_1.VoidType.get("todoGroupBy"));
70
+ // bind the group until ENDLOOP, see unbind(), also when the row type is unknown
71
+ const group = this.findTargetIdentifier((_a = target !== null && target !== void 0 ? target : fsTarget) !== null && _a !== void 0 ? _a : representative, input.scope);
72
+ if (group) {
73
+ input.scope.setGroupMemberType(group, rowType !== null && rowType !== void 0 ? rowType : basic_1.VoidType.get("GroupMember"));
60
74
  }
61
- for (const c of node.findDirectExpressions(Expressions.LoopGroupByComponent)) {
62
- for (const t of c.findDirectExpressions(Expressions.ComponentCompareSingle)) {
63
- component_compare_1.ComponentCompare.runSyntax(t, input);
75
+ }
76
+ /** the row target of a LOOP, it is the group when GROUP BY has no target */
77
+ static findRepresentative(loop) {
78
+ var _a;
79
+ const loopTarget = loop.findDirectExpression(Expressions.LoopTarget);
80
+ return (_a = loopTarget === null || loopTarget === void 0 ? void 0 : loopTarget.findDirectExpression(Expressions.Target)) !== null && _a !== void 0 ? _a : loopTarget === null || loopTarget === void 0 ? void 0 : loopTarget.findDirectExpression(Expressions.FSTarget);
81
+ }
82
+ /** called at the end of a LOOP structure, the group of a LOOP AT ... GROUP BY is not bound after its ENDLOOP */
83
+ static unbind(loop, scope) {
84
+ var _a, _b;
85
+ const groupBy = loop.findDirectExpression(Expressions.LoopGroupBy);
86
+ if (groupBy === undefined) {
87
+ return;
88
+ }
89
+ const groupTarget = groupBy.findDirectExpression(Expressions.LoopGroupByTarget);
90
+ const node = (_b = (_a = groupTarget === null || groupTarget === void 0 ? void 0 : groupTarget.findDirectExpression(Expressions.Target)) !== null && _a !== void 0 ? _a : groupTarget === null || groupTarget === void 0 ? void 0 : groupTarget.findDirectExpression(Expressions.FSTarget)) !== null && _b !== void 0 ? _b : this.findRepresentative(loop);
91
+ const group = this.findTargetIdentifier(node, scope);
92
+ if (group) {
93
+ scope.removeGroupMemberType(group);
94
+ }
95
+ }
96
+ /** LOOP AT GROUP group, the name of the group when it is a variable that no enclosing group loop binds */
97
+ static findUnboundGroup(source, input) {
98
+ if (source === undefined) {
99
+ return undefined;
100
+ }
101
+ const name = this.groupName(source);
102
+ const found = input.scope.findVariable(name);
103
+ if (found === undefined || input.scope.findGroupMemberType(found) !== undefined) {
104
+ return undefined;
105
+ }
106
+ return name;
107
+ }
108
+ /** type of the group key, from GROUP BY expr or GROUP BY ( name = expr ... ) */
109
+ static runKey(node, input) {
110
+ const components = node.findDirectExpressions(Expressions.LoopGroupByComponent);
111
+ if (components.length === 0) {
112
+ // LOOP: the key is the first child of LoopGroupBy, FOR GROUPS: the key follows GROUP BY
113
+ const key = node.get() instanceof Expressions.LoopGroupBy ? node.getFirstChild() : node.findExpressionAfterToken("BY");
114
+ let type = undefined;
115
+ if (key instanceof nodes_1.ExpressionNode && key.get() instanceof Expressions.Source) {
116
+ type = source_1.Source.runSyntax(key, input);
117
+ }
118
+ else if (key instanceof nodes_1.ExpressionNode && key.get() instanceof Expressions.FieldChain) {
119
+ type = field_chain_1.FieldChain.runSyntax(key, input, _reference_1.ReferenceType.DataReadReference);
120
+ }
121
+ return type !== null && type !== void 0 ? type : basic_1.VoidType.get("GroupKey");
122
+ }
123
+ const fields = [];
124
+ let dynamic = false;
125
+ for (const c of components) {
126
+ const single = c.findDirectExpression(Expressions.ComponentCompareSingle);
127
+ if (single) {
128
+ const source = single.findDirectExpression(Expressions.Source);
129
+ const type = source ? source_1.Source.runSyntax(source, input) : undefined;
130
+ const name = single.findDirectExpression(Expressions.ComponentChainSimple);
131
+ if (name === undefined) {
132
+ dynamic = true;
133
+ continue;
134
+ }
135
+ fields.push({ name: name.concatTokens(), type: type !== null && type !== void 0 ? type : basic_1.VoidType.get("GroupKey") });
64
136
  }
137
+ else {
138
+ // GROUP SIZE and GROUP INDEX
139
+ const name = c.findDirectExpression(Expressions.ComponentName);
140
+ if (name) {
141
+ fields.push({ name: name.concatTokens(), type: basic_1.IntegerType.get() });
142
+ }
143
+ }
144
+ }
145
+ if (dynamic === true || fields.length === 0) {
146
+ return basic_1.VoidType.get("GroupKey");
147
+ }
148
+ return new basic_1.StructureType(fields);
149
+ }
150
+ /** the group variable in LOOP AT GROUP group and FOR ... IN GROUP group */
151
+ static findMemberType(source, input) {
152
+ if (source === undefined) {
153
+ return undefined;
154
+ }
155
+ const found = input.scope.findVariable(this.groupName(source));
156
+ return found ? input.scope.findGroupMemberType(found) : undefined;
157
+ }
158
+ static groupName(source) {
159
+ return source.concatTokens().replace(/\s/g, "").replace(/->\*$/, "");
160
+ }
161
+ static findTargetIdentifier(node, scope) {
162
+ var _a;
163
+ var _b, _c;
164
+ if (node === undefined) {
165
+ return undefined;
166
+ }
167
+ const inline = (_b = node.findDirectExpression(Expressions.InlineData)) !== null && _b !== void 0 ? _b : node.findDirectExpression(Expressions.InlineFS);
168
+ let name;
169
+ if (inline) {
170
+ name = (_a = ((_c = inline.findFirstExpression(Expressions.TargetField)) !== null && _c !== void 0 ? _c : inline.findFirstExpression(Expressions.TargetFieldSymbol))) === null || _a === void 0 ? void 0 : _a.getFirstToken().getStr();
171
+ }
172
+ else if (node.getChildren().length === 1) {
173
+ name = node.getFirstToken().getStr();
65
174
  }
175
+ return scope.findVariable(name);
66
176
  }
67
177
  }
68
178
  exports.LoopGroupBy = LoopGroupBy;
@@ -50,6 +50,8 @@ const _reference_1 = require("../_reference");
50
50
  const _syntax_input_1 = require("../_syntax_input");
51
51
  const version_1 = require("../../../version");
52
52
  const _check_database_fields_1 = require("./_check_database_fields");
53
+ const field_chain_1 = require("./field_chain");
54
+ const tokens_1 = require("../../1_lexer/tokens");
53
55
  const isSimple = /^\w+$/;
54
56
  // SQL functions where the result has the same type as the first argument
55
57
  const sameTypeAsFirstArgument = new Set(["UPPER", "LOWER", "LTRIM", "RTRIM"]);
@@ -258,7 +260,7 @@ class Select {
258
260
  if (intoStructure) {
259
261
  const inlineList = intoStructure.findAllExpressions(Expressions.InlineData);
260
262
  if (inlineList.length === 1) {
261
- inline_data_1.InlineData.runSyntax(inlineList[0], input, this.buildStructureType(fields, dbSources, input.scope, from));
263
+ inline_data_1.InlineData.runSyntax(inlineList[0], input, this.buildStructureType(fields, dbSources, input, from));
262
264
  }
263
265
  else {
264
266
  for (const inline of inlineList) {
@@ -325,13 +327,19 @@ class Select {
325
327
  return basic_1.IntegerType.get();
326
328
  }
327
329
  }
328
- static buildStructureType(fields, dbSources, scope, from) {
330
+ static buildStructureType(fields, dbSources, input, from) {
329
331
  var _a, _b, _c, _d, _e, _f;
332
+ const scope = input.scope;
330
333
  if (fields.length === 1 && dbSources.length === 1) {
331
334
  // COUNT( * ) yields an integer regardless of the (possibly dynamic) table
332
335
  if (/^count\(\s*\*\s*\)$/i.test(fields[0].code)) {
333
336
  return this.countResultType(scope);
334
337
  }
338
+ // a host variable yields its own type regardless of the table
339
+ const hostType = this.findHostFieldType(fields[0], input);
340
+ if (hostType) {
341
+ return hostType;
342
+ }
335
343
  const dbType = (_a = dbSources[0]) === null || _a === void 0 ? void 0 : _a.parseType(scope.getRegistry());
336
344
  if (dbType === undefined) {
337
345
  const name = ((_b = dbSources[0]) === null || _b === void 0 ? void 0 : _b.getName()) || "buildStructureTypeError";
@@ -483,6 +491,30 @@ class Select {
483
491
  }
484
492
  return components;
485
493
  }
494
+ /** returns the type of the field list entry if it is a single ABAP host variable, "@var" or "@( var )" */
495
+ static findHostFieldType(field, input) {
496
+ var _a;
497
+ if (!(field.expression.get() instanceof Expressions.SQLField)) {
498
+ return undefined;
499
+ }
500
+ const children = field.expression.getChildren().filter(c => !(c.get() instanceof Expressions.SQLAsName) && c.concatTokens().toUpperCase() !== "AS");
501
+ if (!(((_a = children[0]) === null || _a === void 0 ? void 0 : _a.get()) instanceof tokens_1.WAt)) {
502
+ return undefined;
503
+ }
504
+ // "@var" has two children, "@( var )" has four, anything else is an expression
505
+ const chain = children.length === 2 ? children[1] : children.length === 4 ? children[2] : undefined;
506
+ if (!(chain instanceof nodes_1.ExpressionNode) || !(chain.get() instanceof Expressions.SimpleFieldChain2)) {
507
+ return undefined;
508
+ }
509
+ // only resolve the type here, errors for the host variable are not reported by this lookup
510
+ const issues = [];
511
+ const type = field_chain_1.FieldChain.runSyntax(chain, Object.assign(Object.assign({}, input), { issues }));
512
+ // a generic host type cannot type the inline declaration, keep it voided
513
+ if (issues.length > 0 || type === undefined || type.isGeneric()) {
514
+ return undefined;
515
+ }
516
+ return type;
517
+ }
486
518
  /** returns the SQLFunction node if the field list entry is a single SQL function call */
487
519
  static findFunctionColumn(field, requireAlias = true) {
488
520
  if (requireAlias === true && field.as === "") {
@@ -54,6 +54,7 @@ const conv_body_1 = require("./conv_body");
54
54
  const filter_body_1 = require("./filter_body");
55
55
  const corresponding_body_1 = require("./corresponding_body");
56
56
  const _builtin_1 = require("../_builtin");
57
+ const _builtin_call_1 = require("../_builtin_call");
57
58
  const attribute_chain_1 = require("./attribute_chain");
58
59
  const dereference_1 = require("./dereference");
59
60
  const cast_1 = require("./cast");
@@ -73,6 +74,10 @@ const version_1 = require("../../../version");
73
74
  */
74
75
  // TODO: refactor all these method parameters to objects, this is getting messy
75
76
  class Source {
77
+ // the predicate function in this source is already reported by the caller, Source only checks its arguments
78
+ static predicateReported(source) {
79
+ this.logicalArguments.add(source);
80
+ }
76
81
  static runSyntax(node, input, targetType, writeReference = false, allowGenericDeference = false, readReference = true) {
77
82
  var _a, _b;
78
83
  if (node === undefined) {
@@ -283,6 +288,14 @@ class Source {
283
288
  if (first instanceof nodes_1.ExpressionNode) {
284
289
  const get = first.get();
285
290
  if (get instanceof Expressions.MethodCallChain) {
291
+ const predicate = this.predicateCall(node, first, input);
292
+ if (predicate !== undefined) {
293
+ const message = `Predicate function "${predicate}" can only be used in a logical expression`;
294
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, first.getFirstToken(), message));
295
+ // the arguments are still checked, for their own errors and references
296
+ method_call_chain_1.MethodCallChain.runSyntax(first, input, targetType);
297
+ return basic_1.VoidType.get(_syntax_input_1.CheckSyntaxKey);
298
+ }
286
299
  const found = method_call_chain_1.MethodCallChain.runSyntax(first, input, targetType);
287
300
  context = arithmetic === true ? this.infer(context, found, true) : found;
288
301
  if (context === undefined) {
@@ -535,6 +548,36 @@ class Source {
535
548
  }
536
549
  return targetType;
537
550
  }
551
+ // a predicate function, line_exists( ) or contains( ), is a logical expression and not a value,
552
+ // a system reports it as an unknown method in any operand position other than the argument of boolc( ) or xsdbool( ),
553
+ // which parse as method calls in releases before xsdbool( ) was added, or the bool parameter of boolx( )
554
+ static predicateCall(source, chain, input) {
555
+ var _a, _b;
556
+ if (input.scope.getOpenABAP()) {
557
+ return undefined;
558
+ }
559
+ const call = _builtin_call_1.BuiltInCall.fromChain(chain, input);
560
+ const name = call === undefined ? undefined : _builtin_call_1.BuiltInCall.callName(call);
561
+ const upper = name === null || name === void 0 ? void 0 : name.toUpperCase();
562
+ const param = call === null || call === void 0 ? void 0 : call.findDirectExpression(Expressions.MethodCallParam);
563
+ if (upper === "BOOLC" || upper === "XSDBOOL") {
564
+ const argument = param === null || param === void 0 ? void 0 : param.findDirectExpression(Expressions.Source);
565
+ if (argument !== undefined) {
566
+ this.logicalArguments.add(argument);
567
+ }
568
+ return undefined;
569
+ }
570
+ else if (upper === "BOOLX") {
571
+ for (const p of ((_a = param === null || param === void 0 ? void 0 : param.findDirectExpression(Expressions.ParameterListS)) === null || _a === void 0 ? void 0 : _a.findDirectExpressions(Expressions.ParameterS)) || []) {
572
+ const argument = p.findDirectExpression(Expressions.Source);
573
+ if (((_b = p.findDirectExpression(Expressions.ParameterName)) === null || _b === void 0 ? void 0 : _b.concatTokens().toUpperCase()) === "BOOL" && argument !== undefined) {
574
+ this.logicalArguments.add(argument);
575
+ }
576
+ }
577
+ return undefined;
578
+ }
579
+ return _builtin_1.BuiltIn.isPredicate(name) === true && this.logicalArguments.has(source) === false ? name : undefined;
580
+ }
538
581
  // "NEW ty( )->*" is a syntax error, also in releases where a method call can be dereferenced
539
582
  static isNewObjectDereference(node, deref) {
540
583
  var _a;
@@ -547,4 +590,7 @@ class Source {
547
590
  }
548
591
  }
549
592
  exports.Source = Source;
593
+ // arguments of boolc( ), xsdbool( ) and the bool parameter of boolx( ) parsed as method calls, where a predicate function is allowed,
594
+ // and operands where the caller has already reported the predicate function in more specific terms
595
+ Source.logicalArguments = new WeakSet();
550
596
  //# sourceMappingURL=source.js.map
@@ -35,6 +35,7 @@ var __importStar = (this && this.__importStar) || (function () {
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.SwitchBody = 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 _raise_message_1 = require("../_raise_message");
40
41
  const _syntax_input_1 = require("../_syntax_input");
@@ -44,6 +45,11 @@ class SwitchBody {
44
45
  if (node === undefined) {
45
46
  return;
46
47
  }
48
+ const throwNode = node.findDirectExpression(Expressions.Throw);
49
+ const throwMessage = throwNode ? new _object_oriented_1.ObjectOriented(input.scope).checkClassBasedException() : undefined;
50
+ if (throwNode && throwMessage) {
51
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, throwNode.getFirstToken(), throwMessage));
52
+ }
47
53
  for (const t of node.findDirectExpressions(Expressions.Throw)) {
48
54
  _raise_message_1.RaiseMessage.checkThrow(t, input);
49
55
  }
@@ -110,6 +110,17 @@ class Loop {
110
110
  }
111
111
  if (sourceType instanceof basic_1.TableType) {
112
112
  rowType = sourceType.getRowType();
113
+ }
114
+ else if (concat.startsWith("LOOP AT GROUP ")) {
115
+ const unbound = loop_group_by_1.LoopGroupBy.findUnboundGroup(firstSource, input);
116
+ if (unbound !== undefined) {
117
+ const message = `No group is bound to "${unbound}"`;
118
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
119
+ return;
120
+ }
121
+ rowType = loop_group_by_1.LoopGroupBy.findMemberType(firstSource, input);
122
+ }
123
+ if (rowType) {
113
124
  sourceType = rowType;
114
125
  if (targetConcat === null || targetConcat === void 0 ? void 0 : targetConcat.startsWith("REFERENCE INTO ")) {
115
126
  sourceType = new basic_1.DataReference(sourceType);
@@ -195,7 +206,7 @@ class Loop {
195
206
  }
196
207
  const group = node.findDirectExpression(Expressions.LoopGroupBy);
197
208
  if (group) {
198
- loop_group_by_1.LoopGroupBy.runSyntax(group, input);
209
+ loop_group_by_1.LoopGroupBy.runSyntax(group, input, rowType, loop_group_by_1.LoopGroupBy.findRepresentative(node));
199
210
  }
200
211
  }
201
212
  }
@@ -42,6 +42,7 @@ const target_1 = require("../expressions/target");
42
42
  const message_source_1 = require("../expressions/message_source");
43
43
  const _syntax_input_1 = require("../_syntax_input");
44
44
  const _object_oriented_1 = require("../_object_oriented");
45
+ const _builtin_call_1 = require("../_builtin_call");
45
46
  class Message {
46
47
  runSyntax(node, input) {
47
48
  const exceptionName = node.findDirectExpression(Expressions.ExceptionName);
@@ -60,7 +61,16 @@ class Message {
60
61
  }
61
62
  for (const mss of node.findDirectExpressions(Expressions.MessageSourceSource)) {
62
63
  for (const s of mss.findDirectExpressions(Expressions.Source)) {
64
+ const issueCount = input.issues.length;
63
65
  source_1.Source.runSyntax(s, input);
66
+ // "Arithmetic calculation not permitted here" on a system, whatever the argument
67
+ const call = issueCount === input.issues.length && input.scope.getOpenABAP() === false
68
+ ? _builtin_call_1.BuiltInCall.fromSource(s, input) : undefined;
69
+ if (call !== undefined && _builtin_call_1.BuiltInCall.isNumeric(call)) {
70
+ const message = `Numeric function "${_builtin_call_1.BuiltInCall.callName(call)}" cannot be used in MESSAGE WITH`;
71
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, s.getFirstToken(), message));
72
+ return;
73
+ }
64
74
  }
65
75
  for (const s of mss.findDirectExpressions(Expressions.SimpleSource3)) {
66
76
  source_1.Source.runSyntax(s, input);
@@ -45,6 +45,7 @@ const basic_1 = require("../../types/basic");
45
45
  const nodes_1 = require("../../nodes");
46
46
  class Move {
47
47
  runSyntax(node, input) {
48
+ var _a;
48
49
  const targets = node.findDirectExpressions(Expressions.Target);
49
50
  const firstTarget = targets[0];
50
51
  const inline = firstTarget === null || firstTarget === void 0 ? void 0 : firstTarget.findDirectExpression(Expressions.InlineData);
@@ -85,6 +86,13 @@ class Move {
85
86
  sourceType = dereference_1.Dereference.runSyntax(node, sourceType, input);
86
87
  }
87
88
  if (inline) {
89
+ // the length of a text symbol depends on the text pool, "DATA(x) = TEXT-abc." does not compile
90
+ const sourceChildren = (_a = source === null || source === void 0 ? void 0 : source.getChildren()) !== null && _a !== void 0 ? _a : [];
91
+ if (sourceChildren.length === 1 && sourceChildren[0].get() instanceof Expressions.TextElement) {
92
+ const message = `"${source.concatTokens().toUpperCase()}" has a generic type that cannot be used for declarations`;
93
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, source.getFirstToken(), message));
94
+ return;
95
+ }
88
96
  if (sourceType instanceof basic_1.PackedType && (source === null || source === void 0 ? void 0 : source.findDirectExpression(Expressions.ArithOperator))) {
89
97
  sourceType = new basic_1.PackedType(8, 0);
90
98
  }
@@ -57,6 +57,11 @@ class Raise {
57
57
  input.issues.push((0, _syntax_input_1.syntaxIssue)(input, exceptionName.getFirstToken(), classicMessage));
58
58
  return;
59
59
  }
60
+ const classBasedMessage = exceptionName === undefined && node.findDirectTokenByText("EXCEPTION")
61
+ ? helper.checkClassBasedException() : undefined;
62
+ if (classBasedMessage) {
63
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), classBasedMessage));
64
+ }
60
65
  const classTok = (_a = node.findDirectExpression(Expressions.ClassName)) === null || _a === void 0 ? void 0 : _a.getFirstToken();
61
66
  const className = classTok === null || classTok === void 0 ? void 0 : classTok.getStr();
62
67
  if (classTok && className) {
@@ -42,6 +42,7 @@ const _type_utils_1 = require("../_type_utils");
42
42
  const field_chain_1 = require("../expressions/field_chain");
43
43
  const _reference_1 = require("../_reference");
44
44
  const _syntax_input_1 = require("../_syntax_input");
45
+ const _builtin_call_1 = require("../_builtin_call");
45
46
  class Write {
46
47
  runSyntax(node, input) {
47
48
  // todo, more
@@ -51,7 +52,16 @@ class Write {
51
52
  second = node.getChildren()[2];
52
53
  }
53
54
  for (const s of node.findDirectExpressions(Expressions.Source)) {
55
+ const issueCount = input.issues.length;
54
56
  const type = source_1.Source.runSyntax(s, input);
57
+ // "Arithmetic calculation not permitted here" on a system, while abs( x ) or lines( itab ) is fine
58
+ const call = s === second && issueCount === input.issues.length && input.scope.getOpenABAP() === false
59
+ ? _builtin_call_1.BuiltInCall.fromSource(s, input) : undefined;
60
+ if (call !== undefined && _builtin_call_1.BuiltInCall.isNumeric(call) && _builtin_call_1.BuiltInCall.hasDataObjectArgument(call) === false) {
61
+ const message = `Numeric function "${_builtin_call_1.BuiltInCall.callName(call)}" in WRITE takes only a single data object as argument`;
62
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, s.getFirstToken(), message));
63
+ return;
64
+ }
55
65
  if (s === second
56
66
  && new _type_utils_1.TypeUtils(input.scope).isCharLike(type) === false
57
67
  && new _type_utils_1.TypeUtils(input.scope).isHexLike(type) === false) {
@@ -52,6 +52,7 @@ const statics_1 = require("./structures/statics");
52
52
  const constants_1 = require("./structures/constants");
53
53
  const cleanup_1 = require("./structures/cleanup");
54
54
  const try_1 = require("./structures/try");
55
+ const loop_group_by_1 = require("./expressions/loop_group_by");
55
56
  const class_definition_1 = require("../types/class_definition");
56
57
  const interface_definition_1 = require("../types/interface_definition");
57
58
  const delete_memory_1 = require("./statements/delete_memory");
@@ -477,6 +478,12 @@ class SyntaxLogic {
477
478
  if (loop === true) {
478
479
  this.loopTables.pop();
479
480
  }
481
+ if (node instanceof nodes_1.StructureNode && node.get() instanceof Structures.Loop) {
482
+ const loopStatement = node.findDirectStatement(Statements.Loop);
483
+ if (loopStatement) {
484
+ loop_group_by_1.LoopGroupBy.unbind(loopStatement, this.scope);
485
+ }
486
+ }
480
487
  if (node instanceof nodes_1.StructureNode) {
481
488
  this.sortedLines.leave(node);
482
489
  }
@@ -39,6 +39,7 @@ const Expressions = __importStar(require("../2_statements/expressions"));
39
39
  const events_1 = require("../2_statements/statements/events");
40
40
  const expressions_1 = require("../2_statements/expressions");
41
41
  const method_param_1 = require("../5_syntax/expressions/method_param");
42
+ const _syntax_input_1 = require("../5_syntax/_syntax_input");
42
43
  class EventDefinition extends _identifier_1.Identifier {
43
44
  constructor(node, _visibility, input) {
44
45
  if (!(node.get() instanceof events_1.Events)) {
@@ -61,10 +62,21 @@ class EventDefinition extends _identifier_1.Identifier {
61
62
  }
62
63
  ///////////////
63
64
  parse(node, input) {
65
+ var _a;
66
+ var _b;
64
67
  for (const e of node.findAllExpressions(expressions_1.MethodParam)) {
68
+ if (this.isPassByValue(e) === false) {
69
+ const name = (_b = (_a = e.findDirectExpression(Expressions.MethodParamName)) === null || _a === void 0 ? void 0 : _a.concatTokens()) !== null && _b !== void 0 ? _b : "";
70
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, e.getFirstToken(), "Event parameter " + name + " must be passed by VALUE"));
71
+ }
65
72
  this.parameters.push(method_param_1.MethodParam.runSyntax(e, input, []));
66
73
  }
67
74
  }
75
+ // event parameters can only be passed by value
76
+ isPassByValue(param) {
77
+ const first = param.getFirstToken().getStr().toUpperCase();
78
+ return first === "VALUE" || first === "!VALUE";
79
+ }
68
80
  }
69
81
  exports.EventDefinition = EventDefinition;
70
82
  //# sourceMappingURL=event_definition.js.map
@@ -34,6 +34,13 @@ class FunctionModuleDefinition {
34
34
  isGlobalParameters() {
35
35
  return this.globalParameters;
36
36
  }
37
+ /** the classic exceptions, or the exception classes if isClassBasedExceptions() */
38
+ getExceptions() {
39
+ return this.exceptions;
40
+ }
41
+ isClassBasedExceptions() {
42
+ return this.classBasedExceptions;
43
+ }
37
44
  ///////////////
38
45
  parse(data) {
39
46
  if (data.FUNCNAME === undefined) {
@@ -43,6 +50,8 @@ class FunctionModuleDefinition {
43
50
  this.description = data.SHORT_TEXT;
44
51
  this.parameters = [];
45
52
  this.globalParameters = data.GLOBAL_FLAG === "X";
53
+ this.exceptions = [];
54
+ this.classBasedExceptions = data.EXCEPTION_CLASSES === "X";
46
55
  this.moduleType = FunctionModuleType.regular;
47
56
  if (data.REMOTE_CALL === "R") {
48
57
  this.moduleType = FunctionModuleType.remote;
@@ -111,6 +120,13 @@ class FunctionModuleDefinition {
111
120
  });
112
121
  }
113
122
  }
123
+ if (data.EXCEPTION) {
124
+ for (const exception of (0, xml_utils_1.xmlToArray)(data.EXCEPTION.RSEXC)) {
125
+ if (typeof exception.EXCEPTION === "string") {
126
+ this.exceptions.push(exception.EXCEPTION);
127
+ }
128
+ }
129
+ }
114
130
  }
115
131
  }
116
132
  exports.FunctionModuleDefinition = FunctionModuleDefinition;
@@ -78,7 +78,7 @@ class Registry {
78
78
  }
79
79
  static abaplintVersion() {
80
80
  // magic, see build script "version.js"
81
- return "2.120.110";
81
+ return "2.120.112";
82
82
  }
83
83
  getDDICReferences() {
84
84
  return this.ddicReferences;
@@ -3196,6 +3196,11 @@ ${indentation} output = ${uniqueName}.\n`;
3196
3196
  if (this.lowReg.getConfig().isOpenABAP()) {
3197
3197
  return undefined;
3198
3198
  }
3199
+ else if (node.get() instanceof Statements.Loop
3200
+ && node.concatTokens().toUpperCase().startsWith("LOOP AT GROUP ")) {
3201
+ // rewritten by the LOOP GROUP downport, the inline target is outlined afterwards
3202
+ return undefined;
3203
+ }
3199
3204
  for (const i of node.findAllExpressionsRecursive(Expressions.InlineData)) {
3200
3205
  const nameToken = (_a = i.findDirectExpression(Expressions.TargetField)) === null || _a === void 0 ? void 0 : _a.getFirstToken();
3201
3206
  if (nameToken === undefined) {