Description:
When using the evaluate() function in math.js, the expression 'a ? : 1' returns 1 even when a is truthy. This seems to contradict the expected behavior of the ternary operator, which should follow the format condition ? trueExpr : falseExpr.
Steps to Reproduce:
const math = require('mathjs');
math.evaluate('a ? : 1', { a: 5 }); // returns 1
Expected Behavior:
This expression should either:
- Throw a syntax error due to the missing trueExpr, or
- Return undefined or null if trueExpr is omitted (depending on design choice), but not evaluate to the falseExpr when the condition is truthy.
Actual Behavior:
Returns 1, which is the falseExpr, even though a is 5 (truthy).
Environment:
math.js version: 14.5.2
Node.js version: 20.9.0
Additional Context:
This behavior may indicate a parsing issue or an undocumented fallback mechanism in the ternary operator implementation. It would be helpful to clarify whether this is intended behavior or a bug.
Description:
When using the evaluate() function in math.js, the expression 'a ? : 1' returns 1 even when a is truthy. This seems to contradict the expected behavior of the ternary operator, which should follow the format condition ? trueExpr : falseExpr.
Steps to Reproduce:
const math = require('mathjs');math.evaluate('a ? : 1', { a: 5 }); // returns 1Expected Behavior:
This expression should either:
Actual Behavior:
Returns 1, which is the falseExpr, even though a is 5 (truthy).
Environment:
math.js version: 14.5.2
Node.js version: 20.9.0
Additional Context:
This behavior may indicate a parsing issue or an undocumented fallback mechanism in the ternary operator implementation. It would be helpful to clarify whether this is intended behavior or a bug.