Skip to content

Commit e5bb646

Browse files
authored
fix: #3422 parse dot operators after an implicit multiplication with symbol E (#3425)
1 parent 17a27fa commit e5bb646

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/expression/parse.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ export const createParse = /* #__PURE__ */ factory(name, dependencies, ({
420420
if (parse.isDecimalMark(currentCharacter(state), nextCharacter(state))) {
421421
throw createSyntaxError(state, 'Digit expected, got "' + currentCharacter(state) + '"')
422422
}
423-
} else if (nextCharacter(state) === '.') {
423+
} else if (parse.isDecimalMark(nextCharacter(state), state.expression.charAt(state.index + 2))) {
424424
next(state)
425425
throw createSyntaxError(state, 'Digit expected, got "' + currentCharacter(state) + '"')
426426
}

test/unit-tests/expression/parse.test.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,21 @@ describe('parse', function () {
290290
approxEqual(parseAndEval('2e'), 2 * Math.E)
291291
})
292292

293+
it('should parse dot operators after a value', function () {
294+
approxEqual(parseAndEval('2.*3'), 6)
295+
approxEqual(parseAndEval('2./3'), 2 / 3)
296+
approxEqual(parseAndEval('2.^3'), 2 ** 3)
297+
})
298+
299+
it('should parse dot operators after an implicit multiplication with symbol E', function () {
300+
approxEqual(parseAndEval('2E.*3'), 2 * Math.E * 3)
301+
approxEqual(parseAndEval('2E./3'), 2 * Math.E / 3)
302+
approxEqual(parseAndEval('2E.^3'), 2 * Math.E ** 3)
303+
approxEqual(parseAndEval('2e.*3'), 2 * Math.E * 3)
304+
approxEqual(parseAndEval('2e./3'), 2 * Math.E / 3)
305+
approxEqual(parseAndEval('2e.^3'), 2 * Math.E ** 3)
306+
})
307+
293308
it('should throw an error with invalid numbers', function () {
294309
assert.throws(function () { parseAndEval('.') }, /Value expected/)
295310
assert.throws(function () { parseAndEval('3.2.2') }, SyntaxError)

0 commit comments

Comments
 (0)