Skip to content
This repository has been archived by the owner on Sep 26, 2020. It is now read-only.

Incorrect evaluation when multiplying the result of parenthesis #2

Closed
brooksmckinley opened this issue Jul 18, 2018 · 1 comment
Closed

Comments

@brooksmckinley
Copy link

example:
eval("2 * 4 + 4") will correctly evaluate to 12 while eval("2 * (2 + 2) + (1 + 3)") or even eval(2 * (4) + (4)) will evaluate to 16, even though the two expressions should have the same result.

fn main() {
    assert_eq!(eval("2 * 4 + 4"), Ok(to_value(12)));
    assert_eq!(eval("2 * (4) + (4)"), Ok(to_value(12)));
}
thread 'main' panicked at 'assertion failed: `(left == right)`
  left: `Ok(Number(16))`,
 right: `Ok(Number(12))`', src/main.rs:7:5
@fengcen
Copy link
Owner

fengcen commented Aug 24, 2018

Sorry, I have only recently had time to fix this bug.
Thanks for your feedback.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants