@abaplint/cli 2.115.15 → 2.115.16

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 (2) hide show
  1. package/build/cli.js +101 -37
  2. package/package.json +2 -2
package/build/cli.js CHANGED
@@ -23761,6 +23761,22 @@ class TypeUtils {
23761
23761
  // todo
23762
23762
  return true;
23763
23763
  }
23764
+ isCompareable(source1, source2, node1, node2) {
23765
+ /*
23766
+ console.dir(source1);
23767
+ console.dir(source2);
23768
+ */
23769
+ if (source1 === undefined || source2 === undefined) {
23770
+ return true;
23771
+ }
23772
+ if (source1 instanceof basic_1.HexType && this.isCalculated(node1) && source2 instanceof basic_1.IntegerType) {
23773
+ return false;
23774
+ }
23775
+ if (source2 instanceof basic_1.HexType && this.isCalculated(node2) && source1 instanceof basic_1.IntegerType) {
23776
+ return false;
23777
+ }
23778
+ return true;
23779
+ }
23764
23780
  structureContainsString(structure) {
23765
23781
  for (const c of structure.getComponents()) {
23766
23782
  if (c.type instanceof basic_1.StringType) {
@@ -23790,6 +23806,13 @@ class TypeUtils {
23790
23806
  || node.findFirstExpression(Expressions.ArithOperator) !== undefined;
23791
23807
  return calculated;
23792
23808
  }
23809
+ isAssignableNew(source, target, node) {
23810
+ const calculated = (node === null || node === void 0 ? void 0 : node.findFirstExpression(Expressions.ArithOperator)) !== undefined;
23811
+ if (calculated && source instanceof basic_1.HexType && target instanceof basic_1.IntegerType) {
23812
+ return false;
23813
+ }
23814
+ return this.isAssignable(source, target);
23815
+ }
23793
23816
  isAssignableStrict(source, target, node) {
23794
23817
  var _a, _b, _c, _d, _e, _f, _g, _h, _j;
23795
23818
  const calculated = node ? this.isCalculated(node) : false;
@@ -25389,10 +25412,14 @@ const Expressions = __webpack_require__(/*! ../../2_statements/expressions */ ".
25389
25412
  const source_1 = __webpack_require__(/*! ./source */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/source.js");
25390
25413
  const method_call_chain_1 = __webpack_require__(/*! ./method_call_chain */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/method_call_chain.js");
25391
25414
  const source_field_symbol_1 = __webpack_require__(/*! ./source_field_symbol */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/source_field_symbol.js");
25415
+ const _syntax_input_1 = __webpack_require__(/*! ../_syntax_input */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/_syntax_input.js");
25416
+ const _type_utils_1 = __webpack_require__(/*! ../_type_utils */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/_type_utils.js");
25392
25417
  class Compare {
25393
25418
  static runSyntax(node, input) {
25394
- for (const t of node.findDirectExpressions(Expressions.Source)) {
25395
- source_1.Source.runSyntax(t, input);
25419
+ const sourceTypes = [];
25420
+ const sources = node.findDirectExpressions(Expressions.Source);
25421
+ for (const t of sources) {
25422
+ sourceTypes.push(source_1.Source.runSyntax(t, input));
25396
25423
  }
25397
25424
  for (const t of node.findDirectExpressions(Expressions.SourceFieldSymbolChain)) {
25398
25425
  source_field_symbol_1.SourceFieldSymbol.runSyntax(t, input);
@@ -25400,6 +25427,12 @@ class Compare {
25400
25427
  for (const t of node.findDirectExpressions(Expressions.MethodCallChain)) {
25401
25428
  method_call_chain_1.MethodCallChain.runSyntax(t, input);
25402
25429
  }
25430
+ if (node.findDirectExpression(Expressions.CompareOperator)
25431
+ && new _type_utils_1.TypeUtils(input.scope).isCompareable(sourceTypes[0], sourceTypes[1], sources[0], sources[1]) === false
25432
+ && sourceTypes.length === 2) {
25433
+ const message = "Incompatible types for comparison";
25434
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
25435
+ }
25403
25436
  }
25404
25437
  }
25405
25438
  exports.Compare = Compare;
@@ -29182,53 +29215,84 @@ exports.SQLSource = SQLSource;
29182
29215
 
29183
29216
  Object.defineProperty(exports, "__esModule", ({ value: true }));
29184
29217
  exports.StringTemplate = void 0;
29218
+ const nodes_1 = __webpack_require__(/*! ../../nodes */ "./node_modules/@abaplint/core/build/src/abap/nodes/index.js");
29185
29219
  const basic_1 = __webpack_require__(/*! ../../types/basic */ "./node_modules/@abaplint/core/build/src/abap/types/basic/index.js");
29186
29220
  const Expressions = __webpack_require__(/*! ../../2_statements/expressions */ "./node_modules/@abaplint/core/build/src/abap/2_statements/expressions/index.js");
29187
29221
  const source_1 = __webpack_require__(/*! ./source */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/source.js");
29188
29222
  const _type_utils_1 = __webpack_require__(/*! ../_type_utils */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/_type_utils.js");
29189
29223
  const _syntax_input_1 = __webpack_require__(/*! ../_syntax_input */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/_syntax_input.js");
29224
+ const Tokens = __webpack_require__(/*! ../../1_lexer/tokens */ "./node_modules/@abaplint/core/build/src/abap/1_lexer/tokens/index.js");
29190
29225
  class StringTemplate {
29191
29226
  static runSyntax(node, input) {
29192
29227
  const typeUtils = new _type_utils_1.TypeUtils(input.scope);
29193
29228
  const ret = basic_1.StringType.get();
29194
- for (const templateSource of node.findAllExpressions(Expressions.StringTemplateSource)) {
29195
- const s = templateSource.findDirectExpression(Expressions.Source);
29196
- const type = source_1.Source.runSyntax(s, input, ret);
29197
- if (type === undefined) {
29198
- const message = "No target type determined";
29199
- input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
29200
- return basic_1.VoidType.get(_syntax_input_1.CheckSyntaxKey);
29201
- }
29202
- else if ((typeUtils.isCharLike(type) === false
29203
- && typeUtils.isHexLike(type) === false
29204
- && !(type instanceof basic_1.UTCLongType))
29205
- || type instanceof basic_1.StructureType) {
29206
- const message = "String template, not character like, " + type.constructor.name;
29207
- input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
29208
- return basic_1.VoidType.get(_syntax_input_1.CheckSyntaxKey);
29229
+ for (const child of node.getChildren()) {
29230
+ if (child instanceof nodes_1.ExpressionNode && child.get() instanceof Expressions.StringTemplateSource) {
29231
+ const s = child.findDirectExpression(Expressions.Source);
29232
+ const type = source_1.Source.runSyntax(s, input, ret);
29233
+ if (type === undefined) {
29234
+ const message = "No target type determined";
29235
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
29236
+ return basic_1.VoidType.get(_syntax_input_1.CheckSyntaxKey);
29237
+ }
29238
+ else if ((typeUtils.isCharLike(type) === false
29239
+ && typeUtils.isHexLike(type) === false
29240
+ && !(type instanceof basic_1.UTCLongType))
29241
+ || type instanceof basic_1.StructureType) {
29242
+ const message = "String template, not character like, " + type.constructor.name;
29243
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
29244
+ return basic_1.VoidType.get(_syntax_input_1.CheckSyntaxKey);
29245
+ }
29246
+ const format = child.findDirectExpression(Expressions.StringTemplateFormatting);
29247
+ const formatConcat = format === null || format === void 0 ? void 0 : format.concatTokens();
29248
+ for (const formatSource of (format === null || format === void 0 ? void 0 : format.findAllExpressions(Expressions.Source)) || []) {
29249
+ source_1.Source.runSyntax(formatSource, input);
29250
+ }
29251
+ if (format
29252
+ && (formatConcat === null || formatConcat === void 0 ? void 0 : formatConcat.includes("ALPHA = "))
29253
+ && !(type instanceof basic_1.UnknownType)
29254
+ && !(type instanceof basic_1.VoidType)
29255
+ && !(type instanceof basic_1.StringType)
29256
+ && !(type instanceof basic_1.CLikeType)
29257
+ && !(type instanceof basic_1.CharacterType)
29258
+ && !(type instanceof basic_1.NumericGenericType)
29259
+ && !(type instanceof basic_1.NumericType)
29260
+ && !(type instanceof basic_1.AnyType)) {
29261
+ const message = `Cannot apply ALPHA to this type (${type.constructor.name})`;
29262
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, format.getFirstToken(), message));
29263
+ return basic_1.VoidType.get(_syntax_input_1.CheckSyntaxKey);
29264
+ }
29209
29265
  }
29210
- const format = templateSource.findDirectExpression(Expressions.StringTemplateFormatting);
29211
- const formatConcat = format === null || format === void 0 ? void 0 : format.concatTokens();
29212
- for (const formatSource of (format === null || format === void 0 ? void 0 : format.findAllExpressions(Expressions.Source)) || []) {
29213
- source_1.Source.runSyntax(formatSource, input);
29214
- }
29215
- if (format
29216
- && (formatConcat === null || formatConcat === void 0 ? void 0 : formatConcat.includes("ALPHA = "))
29217
- && !(type instanceof basic_1.UnknownType)
29218
- && !(type instanceof basic_1.VoidType)
29219
- && !(type instanceof basic_1.StringType)
29220
- && !(type instanceof basic_1.CLikeType)
29221
- && !(type instanceof basic_1.CharacterType)
29222
- && !(type instanceof basic_1.NumericGenericType)
29223
- && !(type instanceof basic_1.NumericType)
29224
- && !(type instanceof basic_1.AnyType)) {
29225
- const message = `Cannot apply ALPHA to this type (${type.constructor.name})`;
29226
- input.issues.push((0, _syntax_input_1.syntaxIssue)(input, format.getFirstToken(), message));
29227
- return basic_1.VoidType.get(_syntax_input_1.CheckSyntaxKey);
29266
+ else if (child instanceof nodes_1.TokenNode) {
29267
+ const token = child.get();
29268
+ if (token instanceof Tokens.StringTemplate
29269
+ || token instanceof Tokens.StringTemplateBegin
29270
+ || token instanceof Tokens.StringTemplateMiddle
29271
+ || token instanceof Tokens.StringTemplateEnd) {
29272
+ const issue = this.validateEscapeSequences(token.getStr(), input, child);
29273
+ if (issue) {
29274
+ input.issues.push(issue);
29275
+ return basic_1.VoidType.get(_syntax_input_1.CheckSyntaxKey);
29276
+ }
29277
+ }
29228
29278
  }
29229
29279
  }
29230
29280
  return ret;
29231
29281
  }
29282
+ static validateEscapeSequences(str, input, node) {
29283
+ // Valid escape sequences in ABAP string templates: \|, \{, \}, \\, \n, \r, \t
29284
+ const validEscapes = new Set(["\\|", "\\{", "\\}", "\\\\", "\\n", "\\r", "\\t"]);
29285
+ for (let i = 0; i < str.length; i++) {
29286
+ if (str[i] === "\\") {
29287
+ const escape = str.substring(i, i + 2);
29288
+ if (!validEscapes.has(escape)) {
29289
+ return (0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), `Invalid escape sequence "${escape}" in string template`);
29290
+ }
29291
+ i++; // skip the next character as it's part of the escape sequence
29292
+ }
29293
+ }
29294
+ return undefined;
29295
+ }
29232
29296
  }
29233
29297
  exports.StringTemplate = StringTemplate;
29234
29298
  //# sourceMappingURL=string_template.js.map
@@ -33606,7 +33670,7 @@ class Move {
33606
33670
  return;
33607
33671
  }
33608
33672
  }
33609
- else if (new _type_utils_1.TypeUtils(input.scope).isAssignable(sourceType, targetType) === false) {
33673
+ else if (new _type_utils_1.TypeUtils(input.scope).isAssignableNew(sourceType, targetType, source) === false) {
33610
33674
  const message = "Incompatible types";
33611
33675
  input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
33612
33676
  return;
@@ -55374,7 +55438,7 @@ class Registry {
55374
55438
  }
55375
55439
  static abaplintVersion() {
55376
55440
  // magic, see build script "version.sh"
55377
- return "2.115.15";
55441
+ return "2.115.16";
55378
55442
  }
55379
55443
  getDDICReferences() {
55380
55444
  return this.ddicReferences;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/cli",
3
- "version": "2.115.15",
3
+ "version": "2.115.16",
4
4
  "description": "abaplint - Command Line Interface",
5
5
  "funding": "https://github.com/sponsors/larshp",
6
6
  "bin": {
@@ -38,7 +38,7 @@
38
38
  },
39
39
  "homepage": "https://abaplint.org",
40
40
  "devDependencies": {
41
- "@abaplint/core": "^2.115.15",
41
+ "@abaplint/core": "^2.115.16",
42
42
  "@types/chai": "^4.3.20",
43
43
  "@types/minimist": "^1.2.5",
44
44
  "@types/mocha": "^10.0.10",