Skip to content

Commit

Permalink
Fix empty string conversion into number
Browse files Browse the repository at this point in the history
  • Loading branch information
vinc committed Dec 1, 2022
1 parent f30825f commit 02e8413
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/usr/lisp/number.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,9 @@ impl FromStr for Number {

fn from_str(s: &str) -> Result<Self, Self::Err> {
let err = Err(Err::Reason("Could not parse number".to_string()));
if s.contains('.') {
if s.is_empty() {
return Ok(Number::Int(0));
} else if s.contains('.') {
if let Ok(n) = s.parse() {
return Ok(Number::Float(n));
}
Expand Down

0 comments on commit 02e8413

Please sign in to comment.