@abaplint/core 2.120.101 → 2.120.103

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.
@@ -98,16 +98,19 @@ class SortedKeyWrite {
98
98
  if (this.procedure === undefined) {
99
99
  return;
100
100
  }
101
- // any assignment of a field symbol or reference ends its binding
102
- for (const fs of node.findAllExpressions(Expressions.FSTarget)) {
103
- this.unbind(fs.findFirstExpression(Expressions.TargetFieldSymbol), input.scope);
104
- }
105
- if (node.get() instanceof Statements.Unassign) {
106
- this.unbind(node.findDirectExpression(Expressions.TargetFieldSymbol), input.scope);
107
- }
108
- for (const target of node.findAllExpressions(Expressions.Target)) {
109
- if (target.getChildren().length === 1) {
110
- this.unbind(target.findDirectExpression(Expressions.TargetField), input.scope);
101
+ // any assignment of a field symbol or reference ends its binding,
102
+ // skipped when nothing is bound, this runs for every statement
103
+ if (this.bindings.size > 0) {
104
+ for (const fs of node.findAllExpressions(Expressions.FSTarget)) {
105
+ this.unbind(fs.findFirstExpression(Expressions.TargetFieldSymbol), input.scope);
106
+ }
107
+ if (node.get() instanceof Statements.Unassign) {
108
+ this.unbind(node.findDirectExpression(Expressions.TargetFieldSymbol), input.scope);
109
+ }
110
+ for (const target of node.findAllExpressions(Expressions.Target)) {
111
+ if (target.getChildren().length === 1) {
112
+ this.unbind(target.findDirectExpression(Expressions.TargetField), input.scope);
113
+ }
111
114
  }
112
115
  }
113
116
  const s = node.get();
@@ -43,10 +43,15 @@ const _syntax_input_1 = require("../_syntax_input");
43
43
  // a syntax error. Other types, a dynamic offset or length and "*" (undefined) are left alone, as is
44
44
  // length 0. The offset is applied first, so the length is compared to what remains after the offset.
45
45
  // A substring of a date, time or numeric text field has type n; its bounds are not checked.
46
- // An offset or length on a numeric field (i, int8, p, f, decfloat) is a syntax error, whatever its value.
46
+ // An offset or length on a numeric field (i, int8, p, f, decfloat) is a syntax error, whatever its value,
47
+ // except a length without offset covering the full packed field, eg. "lv_p(5)" for "lv_p(5) TYPE p".
47
48
  function substringType(context, offset, length, node, input) {
48
49
  const numericName = numericTypeName(context);
49
- if (numericName !== undefined) {
50
+ if (context instanceof basic_1.PackedType && offset === undefined && length === context.getLength()) {
51
+ // the offset is checked in a separate call before the length, so this is a length without offset
52
+ return context;
53
+ }
54
+ else if (numericName !== undefined) {
50
55
  const message = `Offset or length specification not possible on a field of numeric type "${numericName}"`;
51
56
  input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
52
57
  return basic_1.VoidType.get(_syntax_input_1.CheckSyntaxKey);
@@ -35,6 +35,7 @@ var __importStar = (this && this.__importStar) || (function () {
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.Loop = void 0;
37
37
  const Expressions = __importStar(require("../../2_statements/expressions"));
38
+ const nodes_1 = require("../../nodes");
38
39
  const basic_1 = require("../../types/basic");
39
40
  const target_1 = require("../expressions/target");
40
41
  const source_1 = require("../expressions/source");
@@ -146,6 +147,17 @@ class Loop {
146
147
  input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
147
148
  return;
148
149
  }
150
+ if (key.type === basic_1.TableAccessType.sorted && key.keyFields.length > 0) {
151
+ // the first component of a sorted secondary key must be compared with = or IS INITIAL
152
+ // in a part of the condition joined by AND, otherwise the WHERE cannot be optimized
153
+ const first = key.keyFields[0].toUpperCase();
154
+ if (this.hasKeyCompare(cond, first) === false) {
155
+ const message = "Loop, WHERE cannot be optimized for secondary key " + name +
156
+ ", key component " + first + " needs a comparison with = or IS INITIAL joined by AND";
157
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
158
+ return;
159
+ }
160
+ }
149
161
  if (!(0, version_1.releaseAtLeast)(input.scope.getRelease(), version_1.Release.v740sp02)) {
150
162
  const compares = cond.findAllExpressionsRecursive(Expressions.ComponentCompare).map(c => c.concatTokens().toUpperCase());
151
163
  for (const keyField of key.keyFields) {
@@ -186,6 +198,31 @@ class Loop {
186
198
  loop_group_by_1.LoopGroupBy.runSyntax(group, input);
187
199
  }
188
200
  }
201
+ // true if a conjunct reachable through AND only, ie. not under OR or NOT, compares the component with = or IS INITIAL
202
+ hasKeyCompare(cond, component) {
203
+ if (cond.findDirectTokenByText("OR") !== undefined) {
204
+ return false;
205
+ }
206
+ for (const child of cond.getChildren()) {
207
+ if (child.get() instanceof Expressions.ComponentCompare && child instanceof nodes_1.ExpressionNode) {
208
+ const concat = child.concatTokens().toUpperCase().replace(/\s+/g, " ");
209
+ if (concat.startsWith(component + " = ")
210
+ || concat.startsWith(component + " EQ ")
211
+ || concat === component + " IS INITIAL") {
212
+ return true;
213
+ }
214
+ }
215
+ else if (child.get() instanceof Expressions.ComponentCondSub
216
+ && child instanceof nodes_1.ExpressionNode
217
+ && child.findDirectTokenByText("NOT") === undefined) {
218
+ const sub = child.findDirectExpression(Expressions.ComponentCond);
219
+ if (sub !== undefined && this.hasKeyCompare(sub, component)) {
220
+ return true;
221
+ }
222
+ }
223
+ }
224
+ return false;
225
+ }
189
226
  }
190
227
  exports.Loop = Loop;
191
228
  //# sourceMappingURL=loop.js.map
@@ -75,7 +75,7 @@ class Registry {
75
75
  }
76
76
  static abaplintVersion() {
77
77
  // magic, see build script "version.js"
78
- return "2.120.101";
78
+ return "2.120.103";
79
79
  }
80
80
  getDDICReferences() {
81
81
  return this.ddicReferences;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/core",
3
- "version": "2.120.101",
3
+ "version": "2.120.103",
4
4
  "description": "abaplint - Core API",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/abaplint.d.ts",