difftreelog
fix std.parseInt should accept + prefix
in: master
2 files changed
crates/jrsonnet-stdlib/src/strings.rsdiffbeforeafterboth128128129#[builtin]129#[builtin]130pub fn builtin_parse_int(str: IStr) -> Result<f64> {130pub fn builtin_parse_int(str: IStr) -> Result<f64> {131 if let Some(raw) = str.strip_prefix('-') {131 let (raw, sign) = str.strip_prefix('-').map_or_else(132 || (str.strip_prefix('+').unwrap_or(&str), 1.0),133 |neg| (neg, -1.0),134 );135132 if raw.is_empty() {136 if raw.is_empty() {133 bail!("integer only consists of a minus")137 bail!("empty integer string: {str:?}")134 }138 }135139136 parse_nat::<10>(raw).map(|value| -value)140 Ok(parse_nat::<10>(raw)? * sign)137 } else {138 if str.is_empty() {139 bail!("empty integer")140 }141142 parse_nat::<10>(str.as_str())143 }144}141}145142146#[builtin]143#[builtin]tests/suite/sjsonnet_issue_1030.jsonnetdiffbeforeafterbothno changes