part of the literal.
Sergey Kaplun:
* added the description and the test for the problem
Part of tarantool/tarantool#8825
---
Branch:
https://github.com/tarantool/luajit/tree/skaplun/fix-binary-number-parsingIssue:
https://github.com/tarantool/tarantool/issues/8825ML:
https://www.freelists.org/post/luajit/Fractional-binary-number-literalsTarantool PR:
https://github.com/tarantool/tarantool/pull/9028Tarantool's CI is red, because static build on aarch64 can't fetch the
LuaJIT's submodule commit somehow. Looks unrelated to the commit:).
src/lj_strscan.c | 1 +
.../fix-binary-number-parsing.test.lua | 17 +++++++++++++++++
2 files changed, 18 insertions(+)
create mode 100644 test/tarantool-tests/fix-binary-number-parsing.test.lua
diff --git a/src/lj_strscan.c b/src/lj_strscan.c
index 11d341ee..a2d92714 100644
--- a/src/lj_strscan.c
+++ b/src/lj_strscan.c
@@ -444,6 +444,7 @@ StrScanFmt lj_strscan_scan(const uint8_t *p, MSize len, TValue *o,
/* Handle decimal point. */
if (dp) {
+ if (base == 2) return STRSCAN_ERROR;
fmt = STRSCAN_NUM;
if (dig) {
ex = (int32_t)(dp-(p-1)); dp = p-1;
diff --git a/test/tarantool-tests/fix-binary-number-parsing.test.lua b/test/tarantool-tests/fix-binary-number-parsing.test.lua
new file mode 100644
index 00000000..df82bd0b
--- /dev/null
+++ b/test/tarantool-tests/fix-binary-number-parsing.test.lua
@@ -0,0 +1,17 @@
+local tap = require('tap')
+
+-- Test file to demonstrate incorrect behaviour of binary number
+-- parsing with fractional dot.
+-- See also:
+--
https://www.freelists.org/post/luajit/Fractional-binary-number-literals+local test = tap.test('fix-binary-number-parsing')
+test:plan(2)
+
+-- Test that incorrect literal with non-0 fractional part still