Parsing unit fails with parentheses and exponents; documentation unclear
- Dominant language
- JavaScript
- Stars
- 15.1k
- Forks
- 1.3k
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the bug**
When trying to parse the unit `lbf/(mile/h)^2` a SyntaxError is thrown.
`SyntaxError: Unexpected "^" in "lbf/(mile/h)^2" at index 12`
This is unexpected since the unit should be valid and math.evaluate() can parse it without issue (see interactive prompt on https://mathjs.org/)
Narrowing down the issue it seems to be related to the `^` after the brackets.
**To Reproduce**
These tests reproduce the issue.
**The original unit**
```js
it('should convert a unit with squared brackets (original)', function () {
const u = Unit.parse('lbf/(mile/h)^2')
assert.notEqual(u, null)
})
```
**Only squared brackets:**
```js
it('should convert a unit with squared brackets (reduced)', function () {
const u = Unit.parse('(h)^2')
assert.notEqual(u, null)
})
```
Contributor guide
Assessment
This issue has not been assessed yet.