@abaplint/core 2.106.3 → 2.106.5

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.
@@ -6980,6 +6980,7 @@ export declare enum Version {
6980
6980
  v755 = "v755",
6981
6981
  v756 = "v756",
6982
6982
  v757 = "v757",
6983
+ v758 = "v758",
6983
6984
  Cloud = "Cloud"
6984
6985
  }
6985
6986
 
@@ -2,9 +2,11 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Return = void 0;
4
4
  const combi_1 = require("../combi");
5
+ const version_1 = require("../../../version");
6
+ const expressions_1 = require("../expressions");
5
7
  class Return {
6
8
  getMatcher() {
7
- return (0, combi_1.str)("RETURN");
9
+ return (0, combi_1.seq)((0, combi_1.str)("RETURN"), (0, combi_1.optPrio)((0, combi_1.ver)(version_1.Version.v758, expressions_1.Source)));
8
10
  }
9
11
  }
10
12
  exports.Return = Return;
@@ -117,6 +117,10 @@ class TypeUtils {
117
117
  if (tname === sname) {
118
118
  return true;
119
119
  }
120
+ /*
121
+ console.dir(sid);
122
+ console.dir(tid);
123
+ */
120
124
  if (!(sid instanceof types_1.ClassDefinition || sid instanceof types_1.InterfaceDefinition)) {
121
125
  const found = this.scope.findObjectDefinition(sid.getName());
122
126
  if (found) {
@@ -336,7 +340,11 @@ class TypeUtils {
336
340
  }
337
341
  }
338
342
  else if (source instanceof basic_1.GenericObjectReferenceType) {
339
- if (target instanceof basic_1.ObjectReferenceType) {
343
+ if (target instanceof basic_1.ObjectReferenceType
344
+ || target instanceof basic_1.StringType
345
+ || target instanceof basic_1.CharacterType
346
+ || target instanceof basic_1.TableType
347
+ || target instanceof basic_1.CLikeType) {
340
348
  return false;
341
349
  }
342
350
  }
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ComponentCompareSimple = void 0;
4
4
  const Expressions = require("../../2_statements/expressions");
5
5
  const nodes_1 = require("../../nodes");
6
+ const _type_utils_1 = require("../_type_utils");
6
7
  const component_chain_1 = require("./component_chain");
7
8
  const source_1 = require("./source");
8
9
  class ComponentCompareSimple {
@@ -17,7 +18,10 @@ class ComponentCompareSimple {
17
18
  targetType = undefined;
18
19
  }
19
20
  else if (c.get() instanceof Expressions.Source) {
20
- new source_1.Source().runSyntax(c, scope, filename, targetType);
21
+ const sourceType = new source_1.Source().runSyntax(c, scope, filename, targetType);
22
+ if (targetType && new _type_utils_1.TypeUtils(scope).isAssignable(sourceType, targetType) === false) {
23
+ throw new Error("ComponentCompareSimple, incompatible types");
24
+ }
21
25
  }
22
26
  else {
23
27
  throw "ComponentCompareSimple, unexpected node";
@@ -98,6 +98,9 @@ class MethodParameters {
98
98
  checkChanging(node, scope, method, filename) {
99
99
  var _a;
100
100
  for (const item of this.parameterListT(node, scope, filename)) {
101
+ if (item.target.findFirstExpression(Expressions.InlineData) !== undefined) {
102
+ throw new Error("CHANGING cannot be inlined");
103
+ }
101
104
  let parameterType = undefined;
102
105
  if (method instanceof basic_1.VoidType) {
103
106
  parameterType = method;
@@ -9,6 +9,7 @@ const field_assignment_1 = require("./field_assignment");
9
9
  const basic_1 = require("../../types/basic");
10
10
  class ValueBody {
11
11
  runSyntax(node, scope, filename, targetType) {
12
+ var _a;
12
13
  if (node === undefined) {
13
14
  return targetType;
14
15
  }
@@ -24,8 +25,16 @@ class ValueBody {
24
25
  forScopes++;
25
26
  }
26
27
  }
28
+ const fields = new Set();
27
29
  for (const s of node.findDirectExpressions(Expressions.FieldAssignment)) {
28
30
  new field_assignment_1.FieldAssignment().runSyntax(s, scope, filename, targetType);
31
+ const fieldname = (_a = s.findDirectExpression(Expressions.FieldSub)) === null || _a === void 0 ? void 0 : _a.concatTokens().toUpperCase();
32
+ if (fieldname) {
33
+ if (fields.has(fieldname)) {
34
+ throw new Error("Duplicate field assignment");
35
+ }
36
+ fields.add(fieldname);
37
+ }
29
38
  }
30
39
  let type = undefined; // todo, this is only correct if there is a single source in the body
31
40
  for (const s of node.findDirectExpressions(Expressions.Source)) {
@@ -3,11 +3,21 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Do = void 0;
4
4
  const Expressions = require("../../2_statements/expressions");
5
5
  const source_1 = require("../expressions/source");
6
+ const target_1 = require("../expressions/target");
7
+ const _type_utils_1 = require("../_type_utils");
8
+ const basic_1 = require("../../types/basic");
6
9
  class Do {
7
10
  runSyntax(node, scope, filename) {
8
- // just recurse
11
+ const afterDo = node.findExpressionAfterToken("DO");
9
12
  for (const s of node.findDirectExpressions(Expressions.Source)) {
10
- new source_1.Source().runSyntax(s, scope, filename);
13
+ const type = new source_1.Source().runSyntax(s, scope, filename);
14
+ if (s === afterDo
15
+ && new _type_utils_1.TypeUtils(scope).isAssignable(type, basic_1.IntegerType.get()) === false) {
16
+ throw new Error("DO TIMES must be numeric");
17
+ }
18
+ }
19
+ for (const t of node.findDirectExpressions(Expressions.Target)) {
20
+ new target_1.Target().runSyntax(t, scope, filename);
11
21
  }
12
22
  }
13
23
  }
@@ -16,7 +16,14 @@ class InsertInternal {
16
16
  if (t) {
17
17
  targetType = new target_1.Target().runSyntax(t, scope, filename);
18
18
  }
19
- if (targetType instanceof basic_1.TableType
19
+ if (!(targetType instanceof basic_1.TableType)
20
+ && !(targetType instanceof basic_1.VoidType)
21
+ && !(targetType instanceof basic_1.AnyType)
22
+ && !(targetType instanceof basic_1.UnknownType)
23
+ && targetType !== undefined) {
24
+ throw new Error("INSERT target must be a table");
25
+ }
26
+ else if (targetType instanceof basic_1.TableType
20
27
  && node.findDirectTokenByText("LINES") === undefined) {
21
28
  targetType = targetType.getRowType();
22
29
  }
@@ -25,6 +32,13 @@ class InsertInternal {
25
32
  source = node.findDirectExpression(Expressions.Source);
26
33
  }
27
34
  const sourceType = source ? new source_1.Source().runSyntax(source, scope, filename, targetType) : targetType;
35
+ if (targetType === undefined
36
+ && !(sourceType instanceof basic_1.TableType)
37
+ && !(sourceType instanceof basic_1.VoidType)
38
+ && !(sourceType instanceof basic_1.AnyType)
39
+ && !(sourceType instanceof basic_1.UnknownType)) {
40
+ throw new Error("INSERT target must be a table");
41
+ }
28
42
  const afterAssigning = node.findExpressionAfterToken("ASSIGNING");
29
43
  if ((afterAssigning === null || afterAssigning === void 0 ? void 0 : afterAssigning.get()) instanceof Expressions.FSTarget) {
30
44
  const inlinefs = afterAssigning === null || afterAssigning === void 0 ? void 0 : afterAssigning.findDirectExpression(Expressions.InlineFS);
@@ -35,9 +49,14 @@ class InsertInternal {
35
49
  new fstarget_1.FSTarget().runSyntax(afterAssigning, scope, filename, sourceType);
36
50
  }
37
51
  }
38
- if (node.findDirectTokenByText("INITIAL") === undefined
39
- && new _type_utils_1.TypeUtils(scope).isAssignableStrict(sourceType, targetType) === false) {
40
- throw new Error("Types not compatible");
52
+ if (node.findDirectTokenByText("INITIAL") === undefined) {
53
+ if (new _type_utils_1.TypeUtils(scope).isAssignableStrict(sourceType, targetType) === false) {
54
+ throw new Error("Types not compatible");
55
+ }
56
+ else if (sourceType instanceof basic_1.CharacterType && targetType instanceof basic_1.StringType) {
57
+ // yea, well, INSERT doesnt convert the values automatically, like everything else?
58
+ throw new Error("Types not compatible");
59
+ }
41
60
  }
42
61
  const afterInto = node.findExpressionAfterToken("INTO");
43
62
  if ((afterInto === null || afterInto === void 0 ? void 0 : afterInto.get()) instanceof Expressions.Target && sourceType) {
@@ -46,11 +46,17 @@ class ReadTable {
46
46
  throw new Error("READ TABLE, FROM must be compatible");
47
47
  }
48
48
  }
49
+ const afterKey = node.findExpressionAfterToken("KEY");
49
50
  for (const s of sources) {
50
51
  if (s === firstSource || s === indexSource || s === fromSource) {
51
52
  continue;
52
53
  }
53
- new source_1.Source().runSyntax(s, scope, filename);
54
+ const type = new source_1.Source().runSyntax(s, scope, filename);
55
+ if (s === afterKey) {
56
+ if (type instanceof basic_1.StringType || type instanceof basic_1.TableType || type instanceof basic_1.ObjectReferenceType) {
57
+ throw new Error("Key cannot be string or table or reference");
58
+ }
59
+ }
54
60
  }
55
61
  const target = node.findDirectExpression(Expressions.ReadTableTarget);
56
62
  if (target) {
@@ -65,7 +65,7 @@ class Registry {
65
65
  }
66
66
  static abaplintVersion() {
67
67
  // magic, see build script "version.sh"
68
- return "2.106.3";
68
+ return "2.106.5";
69
69
  }
70
70
  getDDICReferences() {
71
71
  return this.ddicReferences;
@@ -7,6 +7,7 @@ const _basic_rule_config_1 = require("./_basic_rule_config");
7
7
  const Structures = require("../abap/3_structures/structures");
8
8
  const Expressions = require("../abap/2_statements/expressions");
9
9
  const Statements = require("../abap/2_statements/statements");
10
+ const _statement_1 = require("../abap/2_statements/statements/_statement");
10
11
  const _irule_1 = require("./_irule");
11
12
  const edit_helper_1 = require("../edit_helper");
12
13
  class BeginEndNamesConf extends _basic_rule_config_1.BasicRuleConfig {
@@ -43,6 +44,10 @@ class BeginEndNames extends _abap_rule_1.ABAPRule {
43
44
  if (struc === undefined) {
44
45
  return [];
45
46
  }
47
+ const containsUnknown = file.getStatements().some(s => s.get() instanceof _statement_1.Unknown);
48
+ if (containsUnknown === true) {
49
+ return [];
50
+ }
46
51
  output.push(...this.test(struc, Structures.Data, Statements.DataBegin, Statements.DataEnd, file));
47
52
  output.push(...this.test(struc, Structures.ClassData, Statements.ClassDataBegin, Statements.ClassDataEnd, file));
48
53
  output.push(...this.test(struc, Structures.Constants, Statements.ConstantBegin, Statements.ConstantEnd, file));
@@ -8,6 +8,7 @@ const _abap_rule_1 = require("./_abap_rule");
8
8
  const _basic_rule_config_1 = require("./_basic_rule_config");
9
9
  const _statement_1 = require("../abap/2_statements/statements/_statement");
10
10
  const _irule_1 = require("./_irule");
11
+ const edit_helper_1 = require("../edit_helper");
11
12
  class UnnecessaryPragmaConf extends _basic_rule_config_1.BasicRuleConfig {
12
13
  constructor() {
13
14
  super(...arguments);
@@ -122,7 +123,8 @@ DATA: BEGIN OF blah ##NEEDED,
122
123
  if (statement.findFirstExpression(Expressions.ConstantString) === undefined
123
124
  && statement.findFirstExpression(Expressions.StringTemplate) === undefined) {
124
125
  const message = "There is no text, NO_TEXT can be removed";
125
- return [issue_1.Issue.atToken(file, p, message, this.getMetadata().key, this.getConfig().severity)];
126
+ const fix = edit_helper_1.EditHelper.deleteToken(file, p);
127
+ return [issue_1.Issue.atToken(file, p, message, this.getMetadata().key, this.getConfig().severity, fix)];
126
128
  }
127
129
  return [];
128
130
  }
@@ -134,7 +136,8 @@ DATA: BEGIN OF blah ##NEEDED,
134
136
  const concat = next.concatTokens().toUpperCase();
135
137
  if (concat.includes(" SY-SUBRC")) {
136
138
  const message = "SUBRC_OK can be removed as sy-subrc is checked";
137
- return [issue_1.Issue.atToken(file, p, message, this.getMetadata().key, this.getConfig().severity)];
139
+ const fix = edit_helper_1.EditHelper.deleteToken(file, p);
140
+ return [issue_1.Issue.atToken(file, p, message, this.getMetadata().key, this.getConfig().severity, fix)];
138
141
  }
139
142
  return [];
140
143
  }
@@ -161,7 +164,8 @@ DATA: BEGIN OF blah ##NEEDED,
161
164
  && !(statement.get() instanceof Statements.MethodDef)
162
165
  && statement.findFirstExpression(Expressions.InlineFS) === undefined) {
163
166
  const message = "There is no data definition, NEEDED can be removed";
164
- return [issue_1.Issue.atToken(file, p, message, this.getMetadata().key, this.getConfig().severity)];
167
+ const fix = edit_helper_1.EditHelper.deleteToken(file, p);
168
+ return [issue_1.Issue.atToken(file, p, message, this.getMetadata().key, this.getConfig().severity, fix)];
165
169
  }
166
170
  return [];
167
171
  }
@@ -17,9 +17,10 @@ var Version;
17
17
  Version["v755"] = "v755";
18
18
  Version["v756"] = "v756";
19
19
  Version["v757"] = "v757";
20
+ Version["v758"] = "v758";
20
21
  Version["Cloud"] = "Cloud";
21
22
  })(Version || (exports.Version = Version = {}));
22
- exports.defaultVersion = Version.v757;
23
+ exports.defaultVersion = Version.v758;
23
24
  function getPreviousVersion(v) {
24
25
  if (v === Version.OpenABAP) {
25
26
  return Version.v702;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/core",
3
- "version": "2.106.3",
3
+ "version": "2.106.5",
4
4
  "description": "abaplint - Core API",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/abaplint.d.ts",