Addition with zero yields BigInt parsing errors
Created by: xTibor
Reproduction:
extern crate calc;
fn main() {
let expressions = &["1+0", "0+1", "0+0", "(1+0)+0"];
for e in expressions.iter() {
println!("{} = {:?}", e, calc::eval(e));
}
}
Expected behavior:
1+0 = Ok(Integral(BigInt { sign: Plus, data: BigUint { data: [1] } }, Dec))
0+1 = Ok(Integral(BigInt { sign: Plus, data: BigUint { data: [1] } }, Dec))
0+0 = Ok(Integral(BigInt { sign: Plus, data: BigUint { data: [0] } }, Dec))
(1+0)+0 = Ok(Integral(BigInt { sign: Plus, data: BigUint { data: [1] } }, Dec))
Actual behavior:
1+0 = Ok(Integral(BigInt { sign: Plus, data: BigUint { data: [1] } }, Dec))
0+1 = Err(InvalidNumber("failed to parse bigint/biguint"))
0+0 = Err(InvalidNumber("failed to parse bigint/biguint"))
(1+0)+0 = Err(InvalidNumber("failed to parse bigint/biguint"))
Build information:
rustc -V
: rustc 1.28.0-nightly (5d0631a64 2018-05-30)
git rev-parse HEAD
: 90c85a7e
System: KDE neon 5.12 (Ubuntu 16.04)