@abaplint/runtime 2.7.101 → 2.7.102

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.
@@ -1,12 +1,21 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.div = void 0;
4
+ const throw_error_1 = require("../throw_error");
4
5
  const types_1 = require("../types");
5
6
  const _parse_1 = require("./_parse");
6
7
  function div(left, right) {
7
8
  const l = (0, _parse_1.parse)(left);
8
9
  const r = (0, _parse_1.parse)(right);
9
- if (left instanceof types_1.Integer8 || right instanceof types_1.Integer8) {
10
+ if (r === 0) {
11
+ if (l === 0) {
12
+ return new types_1.Integer().set(0);
13
+ }
14
+ else {
15
+ (0, throw_error_1.throwError)("CX_SY_ZERODIVIDE");
16
+ }
17
+ }
18
+ else if (left instanceof types_1.Integer8 || right instanceof types_1.Integer8) {
10
19
  return new types_1.Integer8().set(Math.floor(l / r));
11
20
  }
12
21
  else {
@@ -1,4 +1,4 @@
1
- import { Float } from "../types";
1
+ import { Float, Integer } from "../types";
2
2
  import { ICharacter } from "../types/_character";
3
3
  import { INumeric } from "../types/_numeric";
4
- export declare function divide(left: INumeric | ICharacter | string | number, right: INumeric | ICharacter | string | number): Float;
4
+ export declare function divide(left: INumeric | ICharacter | string | number, right: INumeric | ICharacter | string | number): Float | Integer;
@@ -7,10 +7,16 @@ const _parse_1 = require("./_parse");
7
7
  // todo, this will only work when the target value is an integer?
8
8
  function divide(left, right) {
9
9
  const r = (0, _parse_1.parse)(right);
10
+ const l = (0, _parse_1.parse)(left);
10
11
  if (r === 0) {
11
- (0, throw_error_1.throwError)("CX_SY_ZERODIVIDE");
12
+ if (l === 0) {
13
+ return new types_1.Integer().set(0);
14
+ }
15
+ else {
16
+ (0, throw_error_1.throwError)("CX_SY_ZERODIVIDE");
17
+ }
12
18
  }
13
- const val = (0, _parse_1.parse)(left) / r;
19
+ const val = l / r;
14
20
  return new types_1.Float().set(val);
15
21
  }
16
22
  exports.divide = divide;
@@ -10,7 +10,10 @@ function templateFormatting(source, options) {
10
10
  }
11
11
  return templateFormatting(source.getPointer(), options);
12
12
  }
13
- else if (source instanceof types_1.Table || source instanceof types_1.HashedTable) {
13
+ else if (source instanceof types_1.Table
14
+ || source instanceof types_1.HashedTable
15
+ || source instanceof types_1.ABAPObject
16
+ || source instanceof types_1.Structure) {
14
17
  throw new Error("STRG_ILLEGAL_DATA_TYPE");
15
18
  }
16
19
  else if (source instanceof types_1.Character) {
@@ -1 +1 @@
1
- export declare function throwError(name: string): void;
1
+ export declare function throwError(name: string): never;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/runtime",
3
- "version": "2.7.101",
3
+ "version": "2.7.102",
4
4
  "description": "Transpiler - Runtime",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/src/index.d.ts",