@abaplint/runtime 2.13.86 → 2.13.87

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.
@@ -22,7 +22,10 @@ class DecFloat34 {
22
22
  this.value = 0;
23
23
  }
24
24
  else if (typeof value === "string") {
25
- this.value = parseFloat(value);
25
+ // get() writes the decimal separator as a comma, and parseFloat stops
26
+ // at one: without this, reading back what this type just wrote gives a
27
+ // truncated number and no error at all
28
+ this.value = parseFloat(value.replace(",", "."));
26
29
  }
27
30
  else if (value instanceof DecFloat34) {
28
31
  this.value = value.getRaw();
@@ -6,7 +6,12 @@ const hex_1 = require("./hex");
6
6
  const xstring_1 = require("./xstring");
7
7
  const integer8_1 = require("./integer8");
8
8
  const decfloat34_1 = require("./decfloat34");
9
- const FLOAT_DIGITS = /^\s*[+-]?(\d+\.?\d*|\.\d+)([eE][+-]?\d+)? *$/;
9
+ // A float writes itself out with a comma for the decimal separator, so
10
+ // reading one back has to accept a comma. Both are allowed rather than only
11
+ // the comma: ABAP source literals carry a point, `CONV f( '0.25' )` is
12
+ // everywhere, and a separator that is legal on the way out and illegal on the
13
+ // way in is not a rule, it is a trap.
14
+ const FLOAT_DIGITS = /^\s*[+-]?(\d+[.,]?\d*|[.,]\d+)([eE][+-]?\d+)? *$/;
10
15
  /*
11
16
  function getNumberParts(x: number) {
12
17
  if(isNaN(x)) {
@@ -67,7 +72,7 @@ class Float {
67
72
  if (FLOAT_DIGITS.test(value) === false) {
68
73
  (0, throw_error_1.throwError)("CX_SY_CONVERSION_NO_NUMBER");
69
74
  }
70
- this.value = parseFloat(value);
75
+ this.value = parseFloat(value.replace(",", "."));
71
76
  }
72
77
  else if (value instanceof integer8_1.Integer8) {
73
78
  this.value = Number(value.get());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/runtime",
3
- "version": "2.13.86",
3
+ "version": "2.13.87",
4
4
  "description": "Transpiler - Runtime",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/src/index.d.ts",