<#21264 Rust options parser fails to parse 1 as fl...
# github-notifications
c
#21264 Rust options parser fails to parse 1 as float, different to legacy parser Issue created by huonw Describe the bug The native parser currently fails to parse a
1
a float, despite code that attempts to paper over the difference: pants/src/rust/engine/options/src/lib.rs Lines 148 to 156 in</pantsbuild/pants/commit/a2acb196216ce5cabe45ee6a039eb5d5f530777a|a2acb19> | if let Some(value) = self.get_string(id)? { | | ---------------------------------------------------------- | | let parsed_as_float = f64::parse(&value) | | .map(Some) | | .map_err(\|e| e.render(self.display(id))); | | if parsed_as_float.is_err() { | | // See if we can parse as an int and coerce it to a float. | | if let Ok(i) = i64::parse(&value) { | | return Ok(Some(i as f64)); | | } | The workaround is either: • add a .0, like 1.0 • set
[GLOBAL].native_options_validation = "ignore"
Reproducer: cd $(mktemp -d) cat > pants.toml <<EOF [GLOBAL] pants_version = "2.22.0.dev2" pantsd_timeout_when_multiple_invocations = 1 EOF # OK: prints the version PANTS_VERSION=2.22.0.dev1 pants version # BUG: Exception: Expected [GLOBAL] pantsd_timeout_when_multiple_invocations to be a float but given 1 pants version Pants version 2.22.0.dev2, 2.22.0rc2, 2.23.0.dev5 OS macOS Additional info This is currently a hard error, but that's being handled in #21262 and #21263. pantsbuild/pants