@abaplint/cli 2.120.46 → 2.120.48

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 +70 -5
  2. package/package.json +2 -2
package/build/cli.js CHANGED
@@ -27471,6 +27471,13 @@ class TypeUtils {
27471
27471
  || type instanceof basic_1.UnknownType
27472
27472
  || type instanceof basic_1.VoidType;
27473
27473
  }
27474
+ isCharLikeForCompare(type) {
27475
+ return type === undefined
27476
+ || type instanceof basic_1.StringType
27477
+ || type instanceof basic_1.CLikeType
27478
+ || type instanceof basic_1.CSequenceType
27479
+ || this.isCharLikeField(type);
27480
+ }
27474
27481
  isCharLike(type) {
27475
27482
  if (type === undefined) {
27476
27483
  return false;
@@ -29812,6 +29819,7 @@ const basic_1 = __webpack_require__(/*! ../../types/basic */ "../core/build/src/
29812
29819
  const _type_utils_1 = __webpack_require__(/*! ../_type_utils */ "../core/build/src/abap/5_syntax/_type_utils.js");
29813
29820
  class Compare {
29814
29821
  static runSyntax(node, input) {
29822
+ var _a;
29815
29823
  const sourceTypes = [];
29816
29824
  const sources = node.findDirectExpressions(Expressions.Source);
29817
29825
  for (const t of sources) {
@@ -29823,8 +29831,16 @@ class Compare {
29823
29831
  for (const t of node.findDirectExpressions(Expressions.MethodCallChain)) {
29824
29832
  method_call_chain_1.MethodCallChain.runSyntax(t, input);
29825
29833
  }
29826
- if (node.findDirectExpression(Expressions.CompareOperator)
29827
- && new _type_utils_1.TypeUtils(input.scope).isCompareable(sourceTypes[0], sourceTypes[1], sources[0], sources[1]) === false
29834
+ const typeUtils = new _type_utils_1.TypeUtils(input.scope);
29835
+ const compareOperator = (_a = node.findDirectExpression(Expressions.CompareOperator)) === null || _a === void 0 ? void 0 : _a.concatTokens().toUpperCase();
29836
+ if (compareOperator === "CS"
29837
+ && sourceTypes.length === 2
29838
+ && sourceTypes.some((type) => typeUtils.isCharLikeForCompare(type) === false)) {
29839
+ const message = "CS operands must be character-like (data type C, N, D, T, or STRING)";
29840
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
29841
+ }
29842
+ else if (node.findDirectExpression(Expressions.CompareOperator)
29843
+ && typeUtils.isCompareable(sourceTypes[0], sourceTypes[1], sources[0], sources[1]) === false
29828
29844
  && sourceTypes.length === 2) {
29829
29845
  let message = "Incompatible types for comparison";
29830
29846
  if ((sourceTypes[0] instanceof basic_1.DateType
@@ -31834,6 +31850,17 @@ var __importStar = (this && this.__importStar) || (function () {
31834
31850
  return result;
31835
31851
  };
31836
31852
  })();
31853
+ var __rest = (this && this.__rest) || function (s, e) {
31854
+ var t = {};
31855
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
31856
+ t[p] = s[p];
31857
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
31858
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
31859
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
31860
+ t[p[i]] = s[p[i]];
31861
+ }
31862
+ return t;
31863
+ };
31837
31864
  Object.defineProperty(exports, "__esModule", ({ value: true }));
31838
31865
  exports.InlineData = void 0;
31839
31866
  const Expressions = __importStar(__webpack_require__(/*! ../../2_statements/expressions */ "../core/build/src/abap/2_statements/expressions/index.js"));
@@ -31866,7 +31893,7 @@ class InlineData {
31866
31893
  input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
31867
31894
  type = basic_1.VoidType.get(_syntax_input_1.CheckSyntaxKey);
31868
31895
  }
31869
- const identifier = new _typed_identifier_1.TypedIdentifier(token, input.filename, type, ["inline" /* IdentifierMeta.InlineDefinition */]);
31896
+ const identifier = new _typed_identifier_1.TypedIdentifier(token, input.filename, this.stripDerivedFromConstant(type), ["inline" /* IdentifierMeta.InlineDefinition */]);
31870
31897
  input.scope.addIdentifier(identifier);
31871
31898
  input.scope.addReference(token, identifier, _reference_1.ReferenceType.DataWriteReference, input.filename);
31872
31899
  }
@@ -31877,6 +31904,26 @@ class InlineData {
31877
31904
  input.scope.addReference(token, identifier, _reference_1.ReferenceType.DataWriteReference, input.filename);
31878
31905
  }
31879
31906
  }
31907
+ // The inferred type is taken from the source expression, which might be a literal.
31908
+ // The variable itself is not a constant, so the relaxations that apply to literals
31909
+ // must not be inherited, eg. a "c" variable is not assignable to a "string" parameter
31910
+ static stripDerivedFromConstant(type) {
31911
+ const data = type.getAbstractTypeData();
31912
+ if ((data === null || data === void 0 ? void 0 : data.derivedFromConstant) !== true) {
31913
+ return type;
31914
+ }
31915
+ const { derivedFromConstant } = data, rest = __rest(data, ["derivedFromConstant"]);
31916
+ if (type instanceof basic_1.CharacterType) {
31917
+ return new basic_1.CharacterType(type.getLength(), rest);
31918
+ }
31919
+ else if (type instanceof basic_1.IntegerType) {
31920
+ return basic_1.IntegerType.get(rest);
31921
+ }
31922
+ else if (type instanceof basic_1.StringType) {
31923
+ return basic_1.StringType.get(rest);
31924
+ }
31925
+ return type;
31926
+ }
31880
31927
  }
31881
31928
  exports.InlineData = InlineData;
31882
31929
  //# sourceMappingURL=inline_data.js.map
@@ -41565,17 +41612,35 @@ const Expressions = __importStar(__webpack_require__(/*! ../../2_statements/expr
41565
41612
  const inline_data_1 = __webpack_require__(/*! ../expressions/inline_data */ "../core/build/src/abap/5_syntax/expressions/inline_data.js");
41566
41613
  const basic_1 = __webpack_require__(/*! ../../types/basic */ "../core/build/src/abap/types/basic/index.js");
41567
41614
  const target_1 = __webpack_require__(/*! ../expressions/target */ "../core/build/src/abap/5_syntax/expressions/target.js");
41615
+ const _syntax_input_1 = __webpack_require__(/*! ../_syntax_input */ "../core/build/src/abap/5_syntax/_syntax_input.js");
41568
41616
  class GetTime {
41569
41617
  runSyntax(node, input) {
41570
41618
  const target = node.findDirectExpression(Expressions.Target);
41619
+ const stamp = node.findDirectTokenByText("STAMP") !== undefined;
41571
41620
  const inline = target === null || target === void 0 ? void 0 : target.findDirectExpression(Expressions.InlineData);
41572
41621
  if (inline) {
41573
41622
  inline_data_1.InlineData.runSyntax(inline, input, new basic_1.PackedType(8, 0));
41574
41623
  }
41575
41624
  else if (target) {
41576
- target_1.Target.runSyntax(target, input);
41625
+ const type = target_1.Target.runSyntax(target, input);
41626
+ if (stamp === true && this.compatibleTimeStamp(type) === false) {
41627
+ const message = "GET TIME STAMP FIELD, target type not compatible";
41628
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
41629
+ return;
41630
+ }
41577
41631
  }
41578
41632
  }
41633
+ // the target must be a timestamp, ie. packed(timestamp and timestampl) or utclong
41634
+ compatibleTimeStamp(type) {
41635
+ return type === undefined
41636
+ || type instanceof basic_1.PackedType
41637
+ || type instanceof basic_1.UTCLongType
41638
+ || type instanceof basic_1.VoidType
41639
+ || type instanceof basic_1.AnyType
41640
+ || type instanceof basic_1.DataType
41641
+ || type instanceof basic_1.UnknownType
41642
+ || type.isGeneric();
41643
+ }
41579
41644
  }
41580
41645
  exports.GetTime = GetTime;
41581
41646
  //# sourceMappingURL=get_time.js.map
@@ -70343,7 +70408,7 @@ class Registry {
70343
70408
  }
70344
70409
  static abaplintVersion() {
70345
70410
  // magic, see build script "version.js"
70346
- return "2.120.46";
70411
+ return "2.120.48";
70347
70412
  }
70348
70413
  getDDICReferences() {
70349
70414
  return this.ddicReferences;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/cli",
3
- "version": "2.120.46",
3
+ "version": "2.120.48",
4
4
  "description": "abaplint - Command Line Interface",
5
5
  "funding": "https://github.com/sponsors/larshp",
6
6
  "bin": {
@@ -39,7 +39,7 @@
39
39
  },
40
40
  "homepage": "https://abaplint.org",
41
41
  "devDependencies": {
42
- "@abaplint/core": "^2.120.46",
42
+ "@abaplint/core": "^2.120.48",
43
43
  "@types/chai": "^4.3.20",
44
44
  "@types/minimist": "^1.2.5",
45
45
  "@types/mocha": "^10.0.10",