@abaplint/core 2.120.86 → 2.120.87

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.
@@ -52,6 +52,7 @@ const expressions_1 = require("../2_statements/expressions");
52
52
  const _builtin_1 = require("./_builtin");
53
53
  const position_1 = require("../../position");
54
54
  const _syntax_input_1 = require("./_syntax_input");
55
+ const version_1 = require("../../version");
55
56
  class BasicTypes {
56
57
  constructor(input) {
57
58
  this.input = input;
@@ -277,7 +278,14 @@ class BasicTypes {
277
278
  }
278
279
  const chainText = typeName.concatTokens().toUpperCase();
279
280
  const f = this.input.scope.getDDIC().lookupBuiltinType(chainText, length, decimals, qualifiedName);
280
- if (f !== undefined) {
281
+ if (f instanceof Types.Integer8Type
282
+ && !(0, version_1.releaseAtLeast)(this.input.scope.getRelease(), version_1.Release.v750)
283
+ && !this.input.scope.getOpenABAP()) {
284
+ const message = "Type INT8 requires 7.50";
285
+ this.input.issues.push((0, _syntax_input_1.syntaxIssue)(this.input, typeName.getFirstToken(), message));
286
+ return basic_1.VoidType.get(_syntax_input_1.CheckSyntaxKey);
287
+ }
288
+ else if (f !== undefined) {
281
289
  return f;
282
290
  }
283
291
  const typ = this.input.scope.findType(chainText);
@@ -96,6 +96,10 @@ class InsertInternal {
96
96
  if (sourceType instanceof basic_1.IntegerType && targetType instanceof basic_1.Integer8Type) {
97
97
  error = true;
98
98
  }
99
+ else if (targetType instanceof basic_1.TableType && targetType.isWithHeader() && sourceType instanceof basic_1.TableType) {
100
+ // LINES OF into a table with header line, compare the row types
101
+ error = new _type_utils_1.TypeUtils(input.scope).isAssignable(sourceType.getRowType(), targetType.getRowType()) === false;
102
+ }
99
103
  else if (new _type_utils_1.TypeUtils(input.scope).isAssignable(sourceType, targetType) === false) {
100
104
  error = true;
101
105
  }
@@ -75,7 +75,7 @@ class Registry {
75
75
  }
76
76
  static abaplintVersion() {
77
77
  // magic, see build script "version.js"
78
- return "2.120.86";
78
+ return "2.120.87";
79
79
  }
80
80
  getDDICReferences() {
81
81
  return this.ddicReferences;
@@ -45,6 +45,7 @@ const Expressions = __importStar(require("../abap/2_statements/expressions"));
45
45
  const Statements = __importStar(require("../abap/2_statements/statements"));
46
46
  const Structures = __importStar(require("../abap/3_structures/structures"));
47
47
  const edit_helper_1 = require("../edit_helper");
48
+ const tokens_1 = require("../abap/1_lexer/tokens");
48
49
  class AlignTypeExpressionsConf extends _basic_rule_config_1.BasicRuleConfig {
49
50
  constructor() {
50
51
  super(...arguments);
@@ -212,12 +213,18 @@ ENDINTERFACE.`,
212
213
  let column = 0;
213
214
  const st = t.findDirectStatements(Statements.Type);
214
215
  for (const s of st) {
215
- const name = s.getChildren()[1];
216
+ const children = s.getChildren();
217
+ const length = s.findDirectExpression(Expressions.ConstantFieldLength);
218
+ const nameEnd = (length !== null && length !== void 0 ? length : children[1]).getLastToken().getEnd();
219
+ const after = children[length ? 3 : 2];
220
+ if (after === undefined || after.getFirstToken() instanceof tokens_1.Punctuation) {
221
+ continue; // no TYPE clause, eg. "foo(1)," with implicit type
222
+ }
216
223
  fields.push({
217
- nameEnd: name.getLastToken().getEnd(),
218
- after: s.getChildren()[2].getFirstToken().getStart()
224
+ nameEnd: nameEnd,
225
+ after: after.getFirstToken().getStart()
219
226
  });
220
- column = Math.max(column, name.getFirstToken().getEnd().getCol() + 1);
227
+ column = Math.max(column, nameEnd.getCol() + 1);
221
228
  }
222
229
  issues.push(...this.check(fields, column, file));
223
230
  }
@@ -331,6 +331,17 @@ Make sure to test the downported code, it might not always be completely correct
331
331
  }
332
332
  }
333
333
  }
334
+ // INSERT with a 702 built-in function as the operand parses in the low version, but 702
335
+ // reads the function as a method call, "Method SUBSTRING does not exist"
336
+ if (ret.length === 0) {
337
+ for (let i = 0; i < lowStatements.length; i++) {
338
+ const issue = this.outlineInsertBuiltin(lowStatements[i], highStatements[i], lowFile, highSyntax);
339
+ if (issue) {
340
+ ret.push(issue);
341
+ break;
342
+ }
343
+ }
344
+ }
334
345
  // INTO after WHERE parses as a valid SELECT in the low version, but is only allowed in
335
346
  // strict SQL syntax, so move it also when the statement is no longer Unknown
336
347
  if (ret.length === 0) {
@@ -1163,6 +1174,40 @@ ${indentation}`);
1163
1174
  }
1164
1175
  return undefined;
1165
1176
  }
1177
+ /** INSERT substring( ... ) INTO TABLE tab, the operand is outlined into a variable */
1178
+ outlineInsertBuiltin(low, high, lowFile, highSyntax) {
1179
+ var _a;
1180
+ if (!(high.get() instanceof Statements.InsertInternal)) {
1181
+ return undefined;
1182
+ }
1183
+ else if (this.lowReg.getConfig().isOpenABAP()) {
1184
+ return undefined;
1185
+ }
1186
+ else if (low.getFirstToken().getStart() instanceof virtual_position_1.VirtualPosition) {
1187
+ return undefined;
1188
+ }
1189
+ // the whole operand is the call, a longer expression is outlined by replaceInsertExpression
1190
+ const source = high.getChildren()[1];
1191
+ if (!(source instanceof nodes_1.ExpressionNode)
1192
+ || !(source.get() instanceof Expressions.SimpleSource4 || source.get() instanceof Expressions.Source)
1193
+ || source.getChildren().length !== 1
1194
+ || !(((_a = source.getFirstChild()) === null || _a === void 0 ? void 0 : _a.get()) instanceof Expressions.MethodCallChain)) {
1195
+ return undefined;
1196
+ }
1197
+ const type = this.builtinReturnType(source, lowFile, highSyntax);
1198
+ if (type === undefined) {
1199
+ return undefined;
1200
+ }
1201
+ const uniqueName = this.uniqueName(high.getFirstToken().getStart(), lowFile.getFilename(), highSyntax);
1202
+ const indentation = " ".repeat(high.getFirstToken().getStart().getCol() - 1);
1203
+ const code = `DATA ${uniqueName} TYPE ${type}.\n` +
1204
+ indentation + `${uniqueName} = ${source.concatTokens()}.\n` +
1205
+ indentation;
1206
+ const fix1 = edit_helper_1.EditHelper.insertAt(lowFile, high.getFirstToken().getStart(), code);
1207
+ const fix2 = edit_helper_1.EditHelper.replaceRange(lowFile, source.getFirstToken().getStart(), source.getLastToken().getEnd(), uniqueName);
1208
+ const fix = edit_helper_1.EditHelper.merge(fix2, fix1);
1209
+ return issue_1.Issue.atToken(lowFile, source.getFirstToken(), "Outline built-in function in INSERT", this.getMetadata().key, this.conf.severity, fix);
1210
+ }
1166
1211
  /** the ABAP type returned by the built-in function this Source starts with, or undefined
1167
1212
  * if it does not start with one, or with one that predates 702 */
1168
1213
  builtinReturnType(source, lowFile, highSyntax) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/core",
3
- "version": "2.120.86",
3
+ "version": "2.120.87",
4
4
  "description": "abaplint - Core API",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/abaplint.d.ts",