@abaplint/cli 2.120.52 → 2.120.53

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 +78 -8
  2. package/package.json +2 -2
package/build/cli.js CHANGED
@@ -24665,12 +24665,15 @@ class ABAPFileInformationParser {
24665
24665
  continue;
24666
24666
  }
24667
24667
  const parameters = this.parseMethodParameters(def);
24668
+ const concatenated = def.concatTokens().toUpperCase();
24668
24669
  methods.push({
24669
24670
  name: methodName.getStr(),
24670
24671
  identifier: new _identifier_1.Identifier(methodName, this.filename),
24671
24672
  isRedefinition: def.findDirectExpression(Expressions.Redefinition) !== undefined,
24672
- isForTesting: def.concatTokens().toUpperCase().includes(" FOR TESTING"),
24673
- isFinal: def.concatTokens().toUpperCase().includes(" FINAL"),
24673
+ isForTesting: concatenated.includes(" FOR TESTING"),
24674
+ isFinal: concatenated.includes(" FINAL"),
24675
+ isDefaultIgnore: concatenated.includes(" DEFAULT IGNORE"),
24676
+ isDefaultFail: concatenated.includes(" DEFAULT FAIL"),
24674
24677
  isAbstract: def.findDirectExpression(Expressions.Abstract) !== undefined,
24675
24678
  isEventHandler: def.findDirectExpression(Expressions.EventHandler) !== undefined,
24676
24679
  visibility,
@@ -34836,11 +34839,15 @@ class Source {
34836
34839
  }
34837
34840
  let hexExpected = false;
34838
34841
  let hexNext = false;
34842
+ // an arithmetic operator has been seen, so the operands that follow
34843
+ // determine a calculation type rather than simply replacing the context
34844
+ let arithmetic = false;
34839
34845
  while (children.length >= 0) {
34840
34846
  if (first instanceof nodes_1.ExpressionNode) {
34841
34847
  const get = first.get();
34842
34848
  if (get instanceof Expressions.MethodCallChain) {
34843
- context = method_call_chain_1.MethodCallChain.runSyntax(first, input, targetType);
34849
+ const found = method_call_chain_1.MethodCallChain.runSyntax(first, input, targetType);
34850
+ context = arithmetic === true ? this.infer(context, found, true) : found;
34844
34851
  if (context === undefined) {
34845
34852
  const message = "Method has no RETURNING value";
34846
34853
  input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
@@ -34848,18 +34855,19 @@ class Source {
34848
34855
  }
34849
34856
  }
34850
34857
  else if (get instanceof Expressions.FieldChain) {
34851
- context = field_chain_1.FieldChain.runSyntax(first, input, type, allowGenericDeference);
34858
+ const found = field_chain_1.FieldChain.runSyntax(first, input, type, allowGenericDeference);
34859
+ context = arithmetic === true ? this.infer(context, found, true) : found;
34852
34860
  }
34853
34861
  else if (get instanceof Expressions.StringTemplate) {
34854
34862
  context = string_template_1.StringTemplate.runSyntax(first, input);
34855
34863
  }
34856
34864
  else if (get instanceof Expressions.Source) {
34857
34865
  const found = Source.runSyntax(first, input);
34858
- context = this.infer(context, found);
34866
+ context = this.infer(context, found, arithmetic);
34859
34867
  }
34860
34868
  else if (get instanceof Expressions.Constant) {
34861
34869
  const found = constant_1.Constant.runSyntax(first);
34862
- context = this.infer(context, found);
34870
+ context = this.infer(context, found, arithmetic);
34863
34871
  }
34864
34872
  else if (get instanceof Expressions.Dereference) {
34865
34873
  context = dereference_1.Dereference.runSyntax(first, context, input);
@@ -34868,6 +34876,7 @@ class Source {
34868
34876
  context = component_chain_1.ComponentChain.runSyntax(context, first, input);
34869
34877
  }
34870
34878
  else if (get instanceof Expressions.ArithOperator) {
34879
+ arithmetic = true;
34871
34880
  if (first.concatTokens() === "**") {
34872
34881
  context = new basic_1.FloatType();
34873
34882
  }
@@ -34914,7 +34923,13 @@ class Source {
34914
34923
  Source.runSyntax(last, input);
34915
34924
  }
34916
34925
  }
34917
- static infer(context, found) {
34926
+ static infer(context, found, arithmetic = false) {
34927
+ if (arithmetic === true) {
34928
+ const calculation = this.calculationType(context, found);
34929
+ if (calculation !== undefined) {
34930
+ return calculation;
34931
+ }
34932
+ }
34918
34933
  if (context instanceof basic_1.FloatType && found instanceof basic_1.IntegerType) {
34919
34934
  return context;
34920
34935
  }
@@ -34928,6 +34943,56 @@ class Source {
34928
34943
  return found;
34929
34944
  }
34930
34945
  }
34946
+ /** The calculation type of an arithmetic expression is the most general of the
34947
+ * operand types. An operand of type c, n, d, t or string is converted into it and
34948
+ * never becomes the result: "lv_f * '0.25'" is a float, not a character field of
34949
+ * length four. Returns undefined when neither operand is numeric, leaving the
34950
+ * decision to the caller. */
34951
+ static calculationType(left, right) {
34952
+ if (left === undefined || right === undefined) {
34953
+ return undefined;
34954
+ }
34955
+ else if (left instanceof basic_1.VoidType || left instanceof unknown_type_1.UnknownType) {
34956
+ // not knowing an operand means not knowing the result
34957
+ return left;
34958
+ }
34959
+ else if (right instanceof basic_1.VoidType || right instanceof unknown_type_1.UnknownType) {
34960
+ return right;
34961
+ }
34962
+ const leftRank = this.numericRank(left);
34963
+ const rightRank = this.numericRank(right);
34964
+ if (leftRank === undefined && rightRank === undefined) {
34965
+ return undefined;
34966
+ }
34967
+ else if (rightRank === undefined) {
34968
+ return left;
34969
+ }
34970
+ else if (leftRank === undefined) {
34971
+ return right;
34972
+ }
34973
+ return leftRank >= rightRank ? left : right;
34974
+ }
34975
+ static numericRank(type) {
34976
+ if (type instanceof basic_1.DecFloat34Type) {
34977
+ return 6;
34978
+ }
34979
+ else if (type instanceof basic_1.DecFloat16Type) {
34980
+ return 5;
34981
+ }
34982
+ else if (type instanceof basic_1.FloatType) {
34983
+ return 4;
34984
+ }
34985
+ else if (type instanceof basic_1.PackedType) {
34986
+ return 3;
34987
+ }
34988
+ else if (type instanceof basic_1.Integer8Type) {
34989
+ return 2;
34990
+ }
34991
+ else if (type instanceof basic_1.IntegerType) {
34992
+ return 1;
34993
+ }
34994
+ return undefined;
34995
+ }
34931
34996
  static addIfInferred(node, input, inferredType) {
34932
34997
  const basic = new basic_types_1.BasicTypes(input);
34933
34998
  const typeExpression = node.findDirectExpression(Expressions.TypeNameOrInfer);
@@ -70579,7 +70644,7 @@ class Registry {
70579
70644
  }
70580
70645
  static abaplintVersion() {
70581
70646
  // magic, see build script "version.js"
70582
- return "2.120.52";
70647
+ return "2.120.53";
70583
70648
  }
70584
70649
  getDDICReferences() {
70585
70650
  return this.ddicReferences;
@@ -84186,6 +84251,11 @@ class ImplementMethods extends _abap_rule_1.ABAPRule {
84186
84251
  return [idef];
84187
84252
  }
84188
84253
  for (const m of this.findInterfaceMethods(idef)) {
84254
+ if (m.method.isDefaultIgnore === true || m.method.isDefaultFail === true) {
84255
+ // the interface says an implementation is optional, so asking for one
84256
+ // reports an error where ABAP reports none
84257
+ continue;
84258
+ }
84189
84259
  if (this.isAbstract(m, interfaceInfo, def)) {
84190
84260
  if (def.isAbstract) {
84191
84261
  continue;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/cli",
3
- "version": "2.120.52",
3
+ "version": "2.120.53",
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.52",
42
+ "@abaplint/core": "^2.120.53",
43
43
  "@types/chai": "^4.3.20",
44
44
  "@types/minimist": "^1.2.5",
45
45
  "@types/mocha": "^10.0.10",