Skip to content

Commit

Permalink
fix: #3267 implicit multiplication with a negative number and unit in
Browse files Browse the repository at this point in the history
  • Loading branch information
josdejong committed Sep 18, 2024
1 parent 2a4faaa commit fb76ac4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
types (#3257). Thanks @smith120bh.
- Fix: #3259 function `symbolicEqual` missing in the TypeScript definitions.
- Fix: #3246 function `leafCount` missing in the TypeScript definitions.
- Fix: #3267 implicit multiplication with a negative number and unit `in`.
- Docs: fix broken links on the Configuration page. Thanks @vassudanagunta.

# 2024-08-27, 13.1.1
Expand Down
1 change: 1 addition & 0 deletions src/expression/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -1074,6 +1074,7 @@ export const createParse = /* #__PURE__ */ factory(name, dependencies, ({
while (true) {
if ((state.tokenType === TOKENTYPE.SYMBOL) ||
(state.token === 'in' && isConstantNode(node)) ||
(state.token === 'in' && isOperatorNode(node) && node.fn === 'unaryMinus' && isConstantNode(node.args[0])) ||
(state.tokenType === TOKENTYPE.NUMBER &&
!isConstantNode(last) &&
(!isOperatorNode(last) || last.op === '!')) ||
Expand Down
5 changes: 5 additions & 0 deletions test/unit-tests/expression/parse.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,11 @@ describe('parse', function () {
approxDeepEqual(parseAndEval('(2+3) in'), new Unit(5, 'in'))
approxDeepEqual(parseAndEval('a in', { a: 5 }), new Unit(5, 'in'))
approxDeepEqual(parseAndEval('0.5in + 1.5in to cm'), new Unit(5.08, 'cm').to('cm'))

assert(parseAndEval('2 meter^2').toString(), '2 meter^2')
assert(parseAndEval('-2 meter^2').toString(), '-2 meter^2')
assert(parseAndEval('2 in^2').toString(), '2 in^2')
assert(parseAndEval('-2 in^2').toString(), '-2 in^2')
})
})

Expand Down

0 comments on commit fb76ac4

Please sign in to comment.