@abaplint/core 2.120.112 → 2.120.114

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 (34) hide show
  1. package/build/abaplint.d.ts +9 -5
  2. package/build/src/abap/2_statements/expressions/method_name.js +1 -1
  3. package/build/src/abap/5_syntax/_builtin_call.js +1 -1
  4. package/build/src/abap/5_syntax/_reserved_names.js +12 -0
  5. package/build/src/abap/5_syntax/basic_types.js +94 -8
  6. package/build/src/abap/5_syntax/expressions/_check_header_line.js +62 -0
  7. package/build/src/abap/5_syntax/expressions/inline_data.js +2 -0
  8. package/build/src/abap/5_syntax/expressions/method_call_chain.js +1 -1
  9. package/build/src/abap/5_syntax/expressions/method_call_param.js +4 -0
  10. package/build/src/abap/5_syntax/expressions/method_parameters.js +4 -0
  11. package/build/src/abap/5_syntax/expressions/type_table.js +21 -1
  12. package/build/src/abap/5_syntax/statements/class_data.js +2 -0
  13. package/build/src/abap/5_syntax/statements/data.js +2 -0
  14. package/build/src/abap/5_syntax/statements/delete_internal.js +11 -0
  15. package/build/src/abap/5_syntax/statements/insert_database.js +12 -0
  16. package/build/src/abap/5_syntax/statements/insert_internal.js +14 -2
  17. package/build/src/abap/5_syntax/statements/modify_internal.js +7 -0
  18. package/build/src/abap/5_syntax/statements/write.js +1 -1
  19. package/build/src/abap/5_syntax/syntax.js +9 -0
  20. package/build/src/abap/types/basic/floating_point_type.js +2 -2
  21. package/build/src/abap/types/basic/hex_type.js +2 -2
  22. package/build/src/abap/types/basic/numeric_type.js +2 -2
  23. package/build/src/abap/types/basic/table_type.js +2 -1
  24. package/build/src/abap/types/method_parameters.js +29 -14
  25. package/build/src/ddic.js +9 -9
  26. package/build/src/objects/table_type.js +8 -7
  27. package/build/src/registry.js +1 -1
  28. package/build/src/rules/check_subrc.js +87 -3
  29. package/build/src/rules/commented_code.js +21 -1
  30. package/build/src/rules/forbidden_statement.js +122 -0
  31. package/build/src/rules/implement_methods.js +20 -6
  32. package/build/src/rules/index.js +1 -0
  33. package/build/src/rules/obsolete_statement.js +31 -1
  34. package/package.json +1 -1
@@ -2922,7 +2922,7 @@ declare type Fix = {
2922
2922
 
2923
2923
  declare class FloatingPointType extends AbstractType {
2924
2924
  private readonly length;
2925
- constructor(length: number, qualifiedName?: string);
2925
+ constructor(length: number, extra?: string | AbstractTypeData);
2926
2926
  getLength(): number;
2927
2927
  toText(): string;
2928
2928
  toABAP(): string;
@@ -3298,7 +3298,7 @@ declare class GetTime implements IStatement {
3298
3298
 
3299
3299
  declare class HexType extends AbstractType {
3300
3300
  private readonly length;
3301
- constructor(length: number, qualifiedName?: string);
3301
+ constructor(length: number, extra?: string | AbstractTypeData);
3302
3302
  getLength(): number;
3303
3303
  toText(): string;
3304
3304
  toABAP(): string;
@@ -4924,7 +4924,8 @@ declare class MethodParameters_2 implements IMethodParameters {
4924
4924
  getExceptions(): string[];
4925
4925
  getParameterDefault(parameter: string): ExpressionNode;
4926
4926
  private parse;
4927
- private checkDuplicateNames;
4927
+ /** reports a parameter with the name of an earlier one, the method definition is kept without it */
4928
+ private isDuplicateName;
4928
4929
  private checkNameLengths;
4929
4930
  private workaroundRAP;
4930
4931
  private add;
@@ -5266,7 +5267,7 @@ declare class NumericGenericType extends AbstractType {
5266
5267
 
5267
5268
  declare class NumericType extends AbstractType {
5268
5269
  private readonly length;
5269
- constructor(length: number, qualifiedName?: string);
5270
+ constructor(length: number, extra?: string | AbstractTypeData);
5270
5271
  getLength(): number;
5271
5272
  toText(): string;
5272
5273
  toABAP(): string;
@@ -7883,6 +7884,8 @@ declare type SyntaxInput = {
7883
7884
  /** checks which can only run once the full object has been traversed, eg. PERFORM parameters,
7884
7885
  * the FORM might be defined after the PERFORM */
7885
7886
  deferred: (() => void)[];
7887
+ /** the statement is inside a LOOP structure */
7888
+ inLoop?: boolean;
7886
7889
  };
7887
7890
 
7888
7891
  export declare class SyntaxLogic {
@@ -7894,6 +7897,7 @@ export declare class SyntaxLogic {
7894
7897
  private readonly reg;
7895
7898
  private scope;
7896
7899
  private loopTables;
7900
+ private loopDepth;
7897
7901
  private currentMethod;
7898
7902
  private sortedLines;
7899
7903
  private helpers;
@@ -8007,7 +8011,7 @@ declare class TableType extends AbstractObject {
8007
8011
  declare class TableType_2 extends AbstractType {
8008
8012
  private readonly rowType;
8009
8013
  private readonly options;
8010
- constructor(rowType: AbstractType, options: ITableOptions, qualifiedName?: string, description?: string);
8014
+ constructor(rowType: AbstractType, options: ITableOptions, qualifiedName?: string, description?: string, ddicName?: string);
8011
8015
  getOptions(): ITableOptions;
8012
8016
  isWithHeader(): boolean;
8013
8017
  getAccessType(): TableAccessType | undefined;
@@ -4,7 +4,7 @@ exports.MethodName = void 0;
4
4
  const combi_1 = require("../combi");
5
5
  class MethodName extends combi_1.Expression {
6
6
  getRunnable() {
7
- return (0, combi_1.regex)(/^(\/\w+\/)?\w+(~\w+)?$/);
7
+ return (0, combi_1.regex)(/^!?(\/\w+\/)?\w+(~\w+)?$/);
8
8
  }
9
9
  }
10
10
  exports.MethodName = MethodName;
@@ -70,7 +70,7 @@ class BuiltInCall {
70
70
  }
71
71
  static callName(call) {
72
72
  var _a;
73
- return (_a = call.findDirectExpression(Expressions.MethodName)) === null || _a === void 0 ? void 0 : _a.concatTokens();
73
+ return (_a = call.findDirectExpression(Expressions.MethodName)) === null || _a === void 0 ? void 0 : _a.concatTokens().replace(/^!/, "");
74
74
  }
75
75
  static isNumeric(call) {
76
76
  var _a, _b, _c;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.checkReservedName = checkReservedName;
4
+ const _syntax_input_1 = require("./_syntax_input");
5
+ /** "me" is the self reference in classes, it cannot be declared as a parameter, attribute or variable */
6
+ function checkReservedName(token, input) {
7
+ if (token === undefined || token.getStr().toLowerCase() !== "me" || input.scope.isAnyOO() === false) {
8
+ return;
9
+ }
10
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, token, "\"me\" is a reserved name, it cannot be declared"));
11
+ }
12
+ //# sourceMappingURL=_reserved_names.js.map
@@ -259,11 +259,59 @@ class BasicTypes {
259
259
  }
260
260
  cloneType(type, qualifiedName) {
261
261
  // nested types(containing "-") will inherit the qualified names if possible
262
- // todo, this needs to be extended to all AbstractTypes instead of just CharacterType
263
- if (type instanceof basic_1.CharacterType
264
- && qualifiedName
265
- && qualifiedName.includes("-") === false) {
266
- type = type.cloneType({ qualifiedName });
262
+ // todo, this needs to be extended to all AbstractTypes
263
+ if (!qualifiedName || qualifiedName.includes("-") === true) {
264
+ return type;
265
+ }
266
+ // TYPES creates a new type, it is no longer the DDIC type
267
+ const data = Object.assign(Object.assign({}, type.getAbstractTypeData()), { qualifiedName, ddicName: undefined });
268
+ if (type instanceof basic_1.CharacterType) {
269
+ type = new basic_1.CharacterType(type.getLength(), data);
270
+ }
271
+ else if (type instanceof Types.IntegerType) {
272
+ type = Types.IntegerType.get(data);
273
+ }
274
+ else if (type instanceof Types.StringType) {
275
+ type = Types.StringType.get(data);
276
+ }
277
+ else if (type instanceof Types.XStringType) {
278
+ type = Types.XStringType.get(data);
279
+ }
280
+ else if (type instanceof Types.Integer8Type) {
281
+ type = new Types.Integer8Type(data);
282
+ }
283
+ else if (type instanceof Types.NumericType) {
284
+ type = new Types.NumericType(type.getLength(), data);
285
+ }
286
+ else if (type instanceof Types.HexType) {
287
+ type = new Types.HexType(type.getLength(), data);
288
+ }
289
+ else if (type instanceof Types.FloatingPointType) {
290
+ type = new Types.FloatingPointType(type.getLength(), data);
291
+ }
292
+ else if (type instanceof Types.DateType) {
293
+ type = new Types.DateType(data);
294
+ }
295
+ else if (type instanceof Types.TimeType) {
296
+ type = new Types.TimeType(data);
297
+ }
298
+ else if (type instanceof Types.PackedType) {
299
+ type = new Types.PackedType(type.getLength(), type.getDecimals(), data);
300
+ }
301
+ else if (type instanceof Types.DecFloat16Type) {
302
+ type = new Types.DecFloat16Type(data);
303
+ }
304
+ else if (type instanceof Types.DecFloat34Type) {
305
+ type = new Types.DecFloat34Type(data);
306
+ }
307
+ else if (type instanceof Types.UTCLongType) {
308
+ type = new Types.UTCLongType(data);
309
+ }
310
+ else if (type instanceof basic_1.StructureType) {
311
+ type = new basic_1.StructureType(type.getComponents().slice(), qualifiedName, undefined, type.getDescription());
312
+ }
313
+ else if (type instanceof basic_1.TableType) {
314
+ type = new basic_1.TableType(type.getRowType(), type.getOptions(), qualifiedName, type.getDescription());
267
315
  }
268
316
  return type;
269
317
  }
@@ -595,6 +643,10 @@ class BasicTypes {
595
643
  if (type === undefined) {
596
644
  return new Types.UnknownType("Type error, could not resolve \"" + name + "\", parseType");
597
645
  }
646
+ // generic tables are reported via DataReference.isGeneric()
647
+ if (type.isGeneric() === true && !(type instanceof basic_1.TableType)) {
648
+ throw new Error("LIKE REF TO not possible, \"" + name + "\" is generic");
649
+ }
598
650
  return new Types.DataReference(type, name);
599
651
  }
600
652
  else if (text === "TYPE STANDARD TABLE"
@@ -1098,15 +1150,23 @@ class BasicTypes {
1098
1150
  checkLengthDecimals(node, text) {
1099
1151
  const length = node.findDirectExpression(Expressions.Length);
1100
1152
  const decimals = node.findDirectExpression(Expressions.Decimals);
1101
- if (length === undefined && decimals === undefined) {
1153
+ const fieldLength = node.get() instanceof Statements.Parameter
1154
+ ? undefined : node.findDirectExpression(Expressions.ConstantFieldLength);
1155
+ if (length === undefined && decimals === undefined && fieldLength === undefined) {
1102
1156
  return undefined;
1103
1157
  }
1104
1158
  else if (text.startsWith("LIKE")) {
1105
- if (decimals === undefined) {
1159
+ if (decimals === undefined && fieldLength === undefined) {
1106
1160
  return undefined;
1107
1161
  }
1108
1162
  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);
1163
+ return (0, _syntax_input_1.syntaxIssue)(this.input, (decimals !== null && decimals !== void 0 ? decimals : node).getFirstToken(), message);
1164
+ }
1165
+ if (fieldLength !== undefined) {
1166
+ const fieldLengthIssue = this.checkFieldLength(node, text);
1167
+ if (fieldLengthIssue !== undefined) {
1168
+ return fieldLengthIssue;
1169
+ }
1110
1170
  }
1111
1171
  const builtin = text.startsWith("TYPE") ? text.substring(4).trim() : "";
1112
1172
  if (length !== undefined && ["C", "N", "X", "P"].includes(builtin) === false) {
@@ -1117,6 +1177,32 @@ class BasicTypes {
1117
1177
  }
1118
1178
  return undefined;
1119
1179
  }
1180
+ // the length in brackets, "DATA foo(8) TYPE d", as a system checks it: c, n, x and p take any length,
1181
+ // d, t and f only their own length, i any length. Their allowed lengths are ignored with a warning,
1182
+ // which is an error in classes and interfaces. Any other type is an error
1183
+ checkFieldLength(node, text) {
1184
+ var _a;
1185
+ const typeNameExpression = node.findFirstExpression(Expressions.TypeName);
1186
+ const typeName = (_a = typeNameExpression === null || typeNameExpression === void 0 ? void 0 : typeNameExpression.concatTokens().toUpperCase()) !== null && _a !== void 0 ? _a : "";
1187
+ if (typeNameExpression === undefined
1188
+ || text.includes(" REF TO ")
1189
+ || ["C", "N", "X", "P"].includes(typeName)) {
1190
+ return undefined;
1191
+ }
1192
+ const token = typeNameExpression.getFirstToken();
1193
+ const ownLength = { "D": 8, "T": 6, "F": 8 };
1194
+ if (ownLength[typeName] !== undefined) {
1195
+ const length = this.findLength(node);
1196
+ if (length !== undefined && length !== ownLength[typeName]) {
1197
+ const message = "Type \"" + typeName + "\" can only have the specified length \"" + ownLength[typeName] + "\" or no length specified at all";
1198
+ return (0, _syntax_input_1.syntaxIssue)(this.input, token, message);
1199
+ }
1200
+ }
1201
+ if ((ownLength[typeName] !== undefined || typeName === "I") && this.input.scope.isAnyOO() === false) {
1202
+ return undefined;
1203
+ }
1204
+ return (0, _syntax_input_1.syntaxIssue)(this.input, token, "Lengths specified in combination with type \"" + typeName + "\" are ignored");
1205
+ }
1120
1206
  findDecimals(node) {
1121
1207
  var _a, _b, _c;
1122
1208
  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();
@@ -0,0 +1,62 @@
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.checkHeaderLine = checkHeaderLine;
37
+ const Expressions = __importStar(require("../../2_statements/expressions"));
38
+ const basic_1 = require("../../types/basic");
39
+ const _syntax_input_1 = require("../_syntax_input");
40
+ const _builtin_1 = require("../_builtin");
41
+ // A table with header line written without [] is the header line, not the table body,
42
+ // so it cannot be passed to a table typed method parameter. Built-in functions like lines( ) use
43
+ // the table body, so they are not checked. Returns true if an issue was reported.
44
+ function checkHeaderLine(source, sourceType, parameterType, method, input) {
45
+ if (source === undefined
46
+ || method instanceof _builtin_1.BuiltInMethod
47
+ || !(parameterType instanceof basic_1.TableType)
48
+ || !(sourceType instanceof basic_1.TableType)
49
+ || sourceType.isWithHeader() === false) {
50
+ return false;
51
+ }
52
+ const chain = source.getChildren().length === 1 ? source.findDirectExpression(Expressions.FieldChain) : undefined;
53
+ const children = (chain === null || chain === void 0 ? void 0 : chain.getChildren()) || [];
54
+ if (chain === undefined || children[children.length - 1].get() instanceof Expressions.TableBody) {
55
+ return false;
56
+ }
57
+ const name = chain.concatTokens();
58
+ const message = `"${name}" is the header line, use "${name}[]" to pass the table body`;
59
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, source.getFirstToken(), message));
60
+ return true;
61
+ }
62
+ //# sourceMappingURL=_check_header_line.js.map
@@ -50,6 +50,7 @@ const _typed_identifier_1 = require("../../types/_typed_identifier");
50
50
  const basic_1 = require("../../types/basic");
51
51
  const _reference_1 = require("../_reference");
52
52
  const _syntax_input_1 = require("../_syntax_input");
53
+ const _reserved_names_1 = require("../_reserved_names");
53
54
  class InlineData {
54
55
  static runSyntax(node, input, type) {
55
56
  var _a;
@@ -58,6 +59,7 @@ class InlineData {
58
59
  const message = "DATA name too long, " + token.getStr();
59
60
  input.issues.push((0, _syntax_input_1.syntaxIssue)(input, token, message));
60
61
  }
62
+ (0, _reserved_names_1.checkReservedName)(token, input);
61
63
  if (token && type) {
62
64
  if (type instanceof basic_1.CSequenceType || type instanceof basic_1.CLikeType) {
63
65
  type = basic_1.StringType.get();
@@ -82,7 +82,7 @@ class MethodCallChain {
82
82
  // for built-in methods set className to undefined
83
83
  const className = context instanceof basic_1.ObjectReferenceType ? context.getIdentifierName() : undefined;
84
84
  const methodToken = (_a = current.findDirectExpression(Expressions.MethodName)) === null || _a === void 0 ? void 0 : _a.getFirstToken();
85
- const methodName = methodToken === null || methodToken === void 0 ? void 0 : methodToken.getStr();
85
+ const methodName = methodToken === null || methodToken === void 0 ? void 0 : methodToken.getStr().replace(/^!/, "");
86
86
  const def = input.scope.findObjectDefinition(className);
87
87
  const isSuper = current === children[2]
88
88
  && first.get() instanceof Expressions.FieldChain
@@ -45,6 +45,7 @@ const _syntax_input_1 = require("../_syntax_input");
45
45
  const constant_1 = require("./constant");
46
46
  const _check_offset_length_1 = require("./_check_offset_length");
47
47
  const _check_text_symbol_1 = require("./_check_text_symbol");
48
+ const _check_header_line_1 = require("./_check_header_line");
48
49
  const _builtin_1 = require("../_builtin");
49
50
  class MethodCallParam {
50
51
  /** returns the type of the unnamed argument, if any */
@@ -122,6 +123,9 @@ class MethodCallParam {
122
123
  else if ((0, _check_text_symbol_1.checkTextSymbol)(child, targetType, input)) {
123
124
  return;
124
125
  }
126
+ else if ((0, _check_header_line_1.checkHeaderLine)(child, sourceType, targetType, method, input)) {
127
+ return;
128
+ }
125
129
  else if (this.isAssignable(sourceType, targetType, child, method, input) === false) {
126
130
  const message = "Method parameter type not compatible";
127
131
  input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
@@ -47,6 +47,7 @@ const field_chain_1 = require("./field_chain");
47
47
  const _reference_1 = require("../_reference");
48
48
  const _check_offset_length_1 = require("./_check_offset_length");
49
49
  const _check_text_symbol_1 = require("./_check_text_symbol");
50
+ const _check_header_line_1 = require("./_check_header_line");
50
51
  const _builtin_1 = require("../_builtin");
51
52
  function normalizeParameterName(name) {
52
53
  return name.replace(/^!/, "").toUpperCase();
@@ -212,6 +213,9 @@ class MethodParameters {
212
213
  if ((0, _check_text_symbol_1.checkTextSymbol)(item.source, parameter.getType(), input)) {
213
214
  return;
214
215
  }
216
+ else if ((0, _check_header_line_1.checkHeaderLine)(item.source, item.sourceType, parameter.getType(), method, input)) {
217
+ return;
218
+ }
215
219
  else if (assignable(item.sourceType, parameter.getType(), item.source) === false) {
216
220
  const message = "Method parameter type not compatible, " + item.name;
217
221
  input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
@@ -63,7 +63,9 @@ class TypeTable {
63
63
  if (type === undefined) {
64
64
  return new _typed_identifier_1.TypedIdentifier(name, input.filename, new basic_1.UnknownType("TableType, fallback"));
65
65
  }
66
- for (const tt of node.findAllExpressions(Expressions.TypeTableKey)) {
66
+ const keys = node.findAllExpressions(Expressions.TypeTableKey);
67
+ TypeTable.checkUniqueness(keys, type);
68
+ for (const tt of keys) {
67
69
  const error = type_table_key_1.TypeTableKey.runSyntax(tt, type);
68
70
  if (error) {
69
71
  type = error;
@@ -71,6 +73,24 @@ class TypeTable {
71
73
  }
72
74
  return new _typed_identifier_1.TypedIdentifier(name, input.filename, type);
73
75
  }
76
+ static checkUniqueness(keys, type) {
77
+ var _a;
78
+ for (const key of keys) {
79
+ if (key.concatTokens().toUpperCase().startsWith("WITH UNIQUE EMPTY KEY")) {
80
+ throw new Error("EMPTY KEY cannot be UNIQUE");
81
+ }
82
+ }
83
+ // the primary key comes first, it is unnamed or named PRIMARY_KEY
84
+ const first = keys[0];
85
+ const keyName = (_a = first === null || first === void 0 ? void 0 : first.findDirectExpression(Expressions.Field)) === null || _a === void 0 ? void 0 : _a.concatTokens().toUpperCase();
86
+ if (type instanceof basic_1.TableType
87
+ && type.getAccessType() === basic_1.TableAccessType.hashed
88
+ && first !== undefined
89
+ && (keyName === undefined || keyName === "PRIMARY_KEY")
90
+ && first.concatTokens().toUpperCase().startsWith("WITH NON-UNIQUE ")) {
91
+ throw new Error("HASHED tables cannot have NON-UNIQUE key");
92
+ }
93
+ }
74
94
  }
75
95
  exports.TypeTable = TypeTable;
76
96
  //# sourceMappingURL=type_table.js.map
@@ -40,6 +40,7 @@ const data_definition_1 = require("../expressions/data_definition");
40
40
  const unknown_type_1 = require("../../types/basic/unknown_type");
41
41
  const _syntax_input_1 = require("../_syntax_input");
42
42
  const basic_1 = require("../../types/basic");
43
+ const _reserved_names_1 = require("../_reserved_names");
43
44
  class ClassData {
44
45
  runSyntax(node, input) {
45
46
  const dd = node.findFirstExpression(Expressions.DataDefinition);
@@ -48,6 +49,7 @@ class ClassData {
48
49
  if (found === undefined) {
49
50
  return undefined;
50
51
  }
52
+ (0, _reserved_names_1.checkReservedName)(found.getToken(), input);
51
53
  if ((found === null || found === void 0 ? void 0 : found.getType().isGeneric()) === true
52
54
  && (found === null || found === void 0 ? void 0 : found.getType().containsVoid()) === false) {
53
55
  const message = "DATA definition cannot be generic, " + found.getName();
@@ -40,12 +40,14 @@ const data_definition_1 = require("../expressions/data_definition");
40
40
  const unknown_type_1 = require("../../types/basic/unknown_type");
41
41
  const _syntax_input_1 = require("../_syntax_input");
42
42
  const basic_1 = require("../../types/basic");
43
+ const _reserved_names_1 = require("../_reserved_names");
43
44
  class Data {
44
45
  runSyntax(node, input) {
45
46
  const name = node.findFirstExpression(Expressions.DefinitionName);
46
47
  const dd = node.findFirstExpression(Expressions.DataDefinition);
47
48
  if (dd) {
48
49
  const id = data_definition_1.DataDefinition.runSyntax(dd, input);
50
+ (0, _reserved_names_1.checkReservedName)(id === null || id === void 0 ? void 0 : id.getToken(), input);
49
51
  if (id && this.isOnlyDigits(id.getName()) && this.allowOnlyDigitsName(node, input) === false) {
50
52
  const message = "not possible to have a name with only digits";
51
53
  input.issues.push((0, _syntax_input_1.syntaxIssue)(input, id.getToken(), message));
@@ -78,6 +78,17 @@ class DeleteInternal {
78
78
  input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
79
79
  return;
80
80
  }
81
+ if (targetType instanceof basic_1.TableType && targetType.isWithHeader() === false) {
82
+ // short forms, "DELETE itab." deletes the current line inside a LOOP, otherwise both use the header line
83
+ const children = node.getChildren().length;
84
+ const short = children === 3 && input.inLoop !== true;
85
+ const shortTable = children === 4 && node.findDirectTokenByText("TABLE") !== undefined;
86
+ if (short || shortTable) {
87
+ const message = "Table does not have header line";
88
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
89
+ return;
90
+ }
91
+ }
81
92
  if (targetType instanceof basic_1.TableType) {
82
93
  targetType = targetType.getRowType();
83
94
  }
@@ -38,9 +38,12 @@ const Expressions = __importStar(require("../../2_statements/expressions"));
38
38
  const source_1 = require("../expressions/source");
39
39
  const dynamic_1 = require("../expressions/dynamic");
40
40
  const database_table_1 = require("../expressions/database_table");
41
+ const _syntax_input_1 = require("../_syntax_input");
42
+ const basic_1 = require("../../types/basic");
41
43
  const _check_database_work_area_1 = require("../expressions/_check_database_work_area");
42
44
  class InsertDatabase {
43
45
  runSyntax(node, input) {
46
+ var _a;
44
47
  const sourceTypes = new Map();
45
48
  for (const s of node.findAllExpressions(Expressions.Source)) {
46
49
  sourceTypes.set(s, source_1.Source.runSyntax(s, input));
@@ -53,6 +56,15 @@ class InsertDatabase {
53
56
  }
54
57
  const dbtab = node.findFirstExpression(Expressions.DatabaseTable);
55
58
  if (dbtab !== undefined) {
59
+ // "INSERT itab." is the short form for an internal table with header line
60
+ const localType = node.getChildren().length === 3
61
+ ? (_a = input.scope.findVariable(dbtab.concatTokens())) === null || _a === void 0 ? void 0 : _a.getType()
62
+ : undefined;
63
+ if (localType instanceof basic_1.TableType && localType.isWithHeader() === false) {
64
+ const message = "Table does not have header line";
65
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
66
+ return;
67
+ }
56
68
  const dbSource = database_table_1.DatabaseTable.runSyntax(dbtab, input);
57
69
  (0, _check_database_work_area_1.checkDatabaseWorkArea)(node, dbSource, sourceTypes, input);
58
70
  }
@@ -45,7 +45,7 @@ const _type_utils_1 = require("../_type_utils");
45
45
  const _syntax_input_1 = require("../_syntax_input");
46
46
  class InsertInternal {
47
47
  runSyntax(node, input) {
48
- var _a;
48
+ var _a, _b;
49
49
  let targetType;
50
50
  const t = node.findDirectExpression(Expressions.Target);
51
51
  if (t) {
@@ -108,9 +108,21 @@ class InsertInternal {
108
108
  // yea, well, INSERT doesnt convert the values automatically, like everything else?
109
109
  error = true;
110
110
  }
111
+ else if ((sourceType instanceof basic_1.StringType || sourceType instanceof basic_1.CharacterType)
112
+ && ((_a = sourceType.getAbstractTypeData()) === null || _a === void 0 ? void 0 : _a.derivedFromConstant) !== true
113
+ && (source === null || source === void 0 ? void 0 : source.findDirectExpression(Expressions.Constant)) === undefined
114
+ && (targetType instanceof basic_1.IntegerType
115
+ || targetType instanceof basic_1.Integer8Type
116
+ || targetType instanceof basic_1.PackedType
117
+ || targetType instanceof basic_1.FloatType
118
+ || targetType instanceof basic_1.DecFloat16Type
119
+ || targetType instanceof basic_1.DecFloat34Type)) {
120
+ // a character-like data object into a table with a numeric row type, no conversion
121
+ error = true;
122
+ }
111
123
  else if (sourceType instanceof basic_1.CharacterType
112
124
  && targetType instanceof basic_1.CharacterType
113
- && ((_a = sourceType.getAbstractTypeData()) === null || _a === void 0 ? void 0 : _a.derivedFromConstant) === true
125
+ && ((_b = sourceType.getAbstractTypeData()) === null || _b === void 0 ? void 0 : _b.derivedFromConstant) === true
114
126
  && sourceType.getLength() !== targetType.getLength()) {
115
127
  // character literal of different length than the row type
116
128
  error = true;
@@ -81,6 +81,13 @@ class ModifyInternal {
81
81
  input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
82
82
  return;
83
83
  }
84
+ if (node.findDirectTokenByText("FROM") === undefined
85
+ && targetType.isWithHeader() === false) {
86
+ // short form, the header line is the work area, eg. "MODIFY itab."
87
+ const message = "Table does not have header line";
88
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
89
+ return;
90
+ }
84
91
  }
85
92
  else if (targetType instanceof basic_1.StructureType) {
86
93
  // it might originate from a TABLES statement
@@ -55,7 +55,7 @@ class Write {
55
55
  const issueCount = input.issues.length;
56
56
  const type = source_1.Source.runSyntax(s, input);
57
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
58
+ const call = s === second && issueCount === input.issues.length
59
59
  ? _builtin_call_1.BuiltInCall.fromSource(s, input) : undefined;
60
60
  if (call !== undefined && _builtin_call_1.BuiltInCall.isNumeric(call) && _builtin_call_1.BuiltInCall.hasDataObjectArgument(call) === false) {
61
61
  const message = `Numeric function "${_builtin_call_1.BuiltInCall.callName(call)}" in WRITE takes only a single data object as argument`;
@@ -361,6 +361,7 @@ class SyntaxLogic {
361
361
  this.issues = [];
362
362
  this.deferred = [];
363
363
  this.loopTables = new _loop_table_change_1.LoopTableChange();
364
+ this.loopDepth = 0;
364
365
  this.sortedLines = new _sorted_key_write_1.SortedKeyWrite();
365
366
  this.reg.getDDICReferences().clear(this.object);
366
367
  this.reg.getMSAGReferences().clear(this.object);
@@ -430,6 +431,10 @@ class SyntaxLogic {
430
431
  const loop = node instanceof nodes_1.StructureNode
431
432
  && node.get() instanceof Structures.Loop
432
433
  && this.loopTables.push(node, this.scope);
434
+ const isLoop = node instanceof nodes_1.StructureNode && node.get() instanceof Structures.Loop;
435
+ if (isLoop) {
436
+ this.loopDepth++;
437
+ }
433
438
  if (node instanceof nodes_1.StructureNode) {
434
439
  this.sortedLines.enter(node, this.currentFile.getFilename());
435
440
  }
@@ -478,6 +483,9 @@ class SyntaxLogic {
478
483
  if (loop === true) {
479
484
  this.loopTables.pop();
480
485
  }
486
+ if (isLoop) {
487
+ this.loopDepth--;
488
+ }
481
489
  if (node instanceof nodes_1.StructureNode && node.get() instanceof Structures.Loop) {
482
490
  const loopStatement = node.findDirectStatement(Statements.Loop);
483
491
  if (loopStatement) {
@@ -563,6 +571,7 @@ class SyntaxLogic {
563
571
  filename,
564
572
  issues: this.issues,
565
573
  deferred: this.deferred,
574
+ inLoop: this.loopDepth > 0,
566
575
  };
567
576
  // todo, refactor
568
577
  if (s instanceof Statements.Type) {
@@ -4,8 +4,8 @@ exports.FloatingPointType = void 0;
4
4
  const _abstract_type_1 = require("./_abstract_type");
5
5
  // this is the DDIC floating point type
6
6
  class FloatingPointType extends _abstract_type_1.AbstractType {
7
- constructor(length, qualifiedName) {
8
- super({ qualifiedName: qualifiedName });
7
+ constructor(length, extra) {
8
+ super(extra === undefined || typeof extra === "string" ? { qualifiedName: extra } : extra);
9
9
  if (length <= 0) {
10
10
  throw new Error("Bad LENGTH, Floating Point");
11
11
  }
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.HexType = void 0;
4
4
  const _abstract_type_1 = require("./_abstract_type");
5
5
  class HexType extends _abstract_type_1.AbstractType {
6
- constructor(length, qualifiedName) {
7
- super({ qualifiedName: qualifiedName });
6
+ constructor(length, extra) {
7
+ super(extra === undefined || typeof extra === "string" ? { qualifiedName: extra } : extra);
8
8
  if (length <= 0) {
9
9
  throw new Error("Bad LENGTH, Hex");
10
10
  }
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.NumericType = void 0;
4
4
  const _abstract_type_1 = require("./_abstract_type");
5
5
  class NumericType extends _abstract_type_1.AbstractType {
6
- constructor(length, qualifiedName) {
7
- super({ qualifiedName: qualifiedName });
6
+ constructor(length, extra) {
7
+ super(extra === undefined || typeof extra === "string" ? { qualifiedName: extra } : extra);
8
8
  if (length <= 0) {
9
9
  throw new Error("Bad LENGTH, Numeric");
10
10
  }
@@ -17,11 +17,12 @@ var TableKeyType;
17
17
  TableKeyType["empty"] = "EMPTY";
18
18
  })(TableKeyType || (exports.TableKeyType = TableKeyType = {}));
19
19
  class TableType extends _abstract_type_1.AbstractType {
20
- constructor(rowType, options, qualifiedName, description) {
20
+ constructor(rowType, options, qualifiedName, description, ddicName) {
21
21
  var _a;
22
22
  super({
23
23
  qualifiedName: qualifiedName,
24
24
  description: description,
25
+ ddicName: ddicName,
25
26
  });
26
27
  this.rowType = rowType;
27
28
  this.options = options;