git.delta.rocks / jrsonnet / refs/commits / 7af406eaa740

difftreelog

feat return NumValue directly from parser

rlsuqplzYaroslav Bolyukin2026-04-25parent: #eee6c62.patch.diff
in: master

15 files changed

modifiedbindings/jsonnet/src/val_make.rsdiffbeforeafterboth
--- a/bindings/jsonnet/src/val_make.rs
+++ b/bindings/jsonnet/src/val_make.rs
@@ -5,10 +5,7 @@
 	os::raw::{c_char, c_double, c_int},
 };
 
-use jrsonnet_evaluator::{
-	ObjValue, Val,
-	val::{ArrValue, NumValue},
-};
+use jrsonnet_evaluator::{NumValue, ObjValue, Val};
 
 use crate::VM;
 
modifiedcrates/jrsonnet-evaluator/src/error.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/error.rs
+++ b/crates/jrsonnet-evaluator/src/error.rs
@@ -2,7 +2,9 @@
 
 use jrsonnet_gcmodule::{Acyclic, Trace};
 use jrsonnet_interner::IStr;
-use jrsonnet_ir::{BinaryOpType, Source, SourcePath, Span, Spanned, UnaryOpType};
+use jrsonnet_ir::{
+	BinaryOpType, ConvertNumValueError, Source, SourcePath, Span, Spanned, UnaryOpType,
+};
 use jrsonnet_types::ValType;
 use thiserror::Error;
 
@@ -11,7 +13,6 @@
 	function::{CallLocation, FunctionSignature, ParamName},
 	stdlib::format::FormatError,
 	typed::TypeLocError,
-	val::ConvertNumValueError,
 };
 
 #[derive(Debug, Clone)]
@@ -228,6 +229,11 @@
 		Self::new(e)
 	}
 }
+impl From<ConvertNumValueError> for Error {
+	fn from(e: ConvertNumValueError) -> Self {
+		Self::new(ErrorKind::ConvertNumValue(e))
+	}
+}
 
 impl From<Infallible> for Error {
 	fn from(_value: Infallible) -> Self {
modifiedcrates/jrsonnet-evaluator/src/evaluate/mod.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/evaluate/mod.rs
+++ b/crates/jrsonnet-evaluator/src/evaluate/mod.rs
@@ -21,7 +21,7 @@
 	function::{CallLocation, FuncDesc, FuncVal, PreparedFuncVal},
 	in_frame,
 	typed::{FromUntyped, IntoUntyped as _, Typed},
-	val::{CachedUnbound, IndexableVal, NumValue, StrValue, Thunk},
+	val::{CachedUnbound, IndexableVal, StrValue, Thunk},
 	with_state,
 };
 pub mod destructure;
@@ -58,9 +58,7 @@
 	}
 	Some(match expr {
 		Expr::Str(s) => Val::string(s.clone()),
-		Expr::Num(n) => {
-			Val::Num(NumValue::new(*n).expect("parser will not allow non-finite values"))
-		}
+		Expr::Num(n) => Val::Num(*n),
 		Expr::Literal(LiteralType::False) => Val::Bool(false),
 		Expr::Literal(LiteralType::True) => Val::Bool(true),
 		Expr::Literal(LiteralType::Null) => Val::Null,
modifiedcrates/jrsonnet-evaluator/src/integrations/serde.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/integrations/serde.rs
+++ b/crates/jrsonnet-evaluator/src/integrations/serde.rs
@@ -1,6 +1,7 @@
 use std::borrow::Cow;
 
 use jrsonnet_interner::{IBytes, IStr};
+use jrsonnet_ir::NumValue;
 use serde::{
 	Deserialize, Serialize, Serializer,
 	de::{self, Visitor},
@@ -12,7 +13,6 @@
 
 use crate::{
 	Error as JrError, ObjValue, ObjValueBuilder, Result, Val, in_description_frame, runtime_error,
-	val::NumValue,
 };
 
 impl<'de> Deserialize<'de> for Val {
modifiedcrates/jrsonnet-evaluator/src/lib.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/lib.rs
+++ b/crates/jrsonnet-evaluator/src/lib.rs
@@ -42,6 +42,7 @@
 use jrsonnet_gcmodule::{Cc, Trace, cc_dyn};
 pub use jrsonnet_interner::{IBytes, IStr};
 pub use jrsonnet_ir as parser;
+pub use jrsonnet_ir::NumValue;
 use jrsonnet_ir::{Expr, Source, SourcePath};
 #[doc(hidden)]
 pub use jrsonnet_macros;
modifiedcrates/jrsonnet-evaluator/src/stdlib/format.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/stdlib/format.rs
+++ b/crates/jrsonnet-evaluator/src/stdlib/format.rs
@@ -829,7 +829,7 @@
 #[cfg(test)]
 pub mod test_format {
 	use super::*;
-	use crate::val::NumValue;
+	use crate::NumValue;
 
 	#[test]
 	fn parse() {
modifiedcrates/jrsonnet-evaluator/src/typed/conversions.rsdiffbeforeafterboth
after · crates/jrsonnet-evaluator/src/typed/conversions.rs
1use std::{any::TypeId, collections::BTreeMap, marker::PhantomData, mem::transmute, ops::Deref};23use jrsonnet_gcmodule::Trace;4use jrsonnet_interner::{IBytes, IStr};5use jrsonnet_ir::NumValue;6pub use jrsonnet_ir::{MAX_SAFE_INTEGER, MIN_SAFE_INTEGER};7use jrsonnet_types::{ComplexValType, ValType};89use crate::{10	ObjValue, ObjValueBuilder, Result, ResultExt, Thunk, Val,11	arr::ArrValue,12	bail,13	function::FuncVal,14	typed::CheckType,15	val::{IndexableVal, StrValue, ThunkMapper},16};1718#[doc(hidden)]19pub mod __typed_macro_prelude {20	pub use ::jrsonnet_evaluator::{21		IStr, ObjValue, ObjValueBuilder, State, Val,22		error::{ErrorKind, Result as JrResult},23		typed::{24			CheckType, ComplexValType, FromUntyped, IntoUntyped, ParseTypedObj, SerializeTypedObj,25			Typed,26		},27	};28}29pub use jrsonnet_macros::{FromUntyped, IntoUntyped, Typed};3031#[derive(Trace)]32struct ThunkFromUntyped<K: Trace>(PhantomData<fn() -> K>);33impl<K> ThunkMapper<Val> for ThunkFromUntyped<K>34where35	K: Typed + FromUntyped + Trace,36{37	type Output = K;3839	fn map(self, from: Val) -> Result<Self::Output> {40		K::from_untyped(from)41	}42}43impl<K: Trace> Default for ThunkFromUntyped<K> {44	fn default() -> Self {45		Self(PhantomData)46	}47}48#[derive(Trace)]49struct ThunkIntoUntyped<K: Trace>(PhantomData<fn() -> K>);50impl<K> ThunkMapper<K> for ThunkIntoUntyped<K>51where52	K: Typed + Trace + IntoUntyped,53{54	type Output = Val;5556	fn map(self, from: K) -> Result<Self::Output> {57		K::into_untyped(from)58	}59}60impl<K: Trace> Default for ThunkIntoUntyped<K> {61	fn default() -> Self {62		Self(PhantomData)63	}64}6566#[diagnostic::on_unimplemented(67	note = "don't implement `ParseTypedObj` directly, it is automatically provided by `FromUntyped` derive"68)]69pub trait ParseTypedObj: Typed {70	fn parse(obj: &ObjValue) -> Result<Self>;71}7273#[diagnostic::on_unimplemented(74	note = "don't implement `SerializeTypedObj` directly, it is automatically provided by `IntoUntyped` derive"75)]76pub trait SerializeTypedObj: Typed {77	fn serialize(self, out: &mut ObjValueBuilder) -> Result<()>;78	fn into_object(self) -> Result<ObjValue> {79		let mut builder = ObjValueBuilder::new();80		self.serialize(&mut builder)?;81		Ok(builder.build())82	}83}8485pub trait Typed: Sized {86	const TYPE: &'static ComplexValType;87}88impl<T> Typed for &T89where90	T: Typed,91{92	const TYPE: &'static ComplexValType = <&T as Typed>::TYPE;93}94pub trait IntoUntyped: Typed {95	// Whatever caller should use `into_lazy_untyped` instead of `into_untyped`96	fn provides_lazy() -> bool {97		false98	}99	fn into_untyped(typed: Self) -> Result<Val>;100	fn into_lazy_untyped(typed: Self) -> Thunk<Val> {101		Thunk::from(Self::into_untyped(typed))102	}103}104105pub trait IntoUntypedResult: Typed {106	/// Hack to make builtins be able to return non-result values, and make macros able to convert those values to result107	/// This method returns identity in impl Typed for Result, and should not be overriden108	#[doc(hidden)]109	fn into_untyped_result(typed: Self) -> Result<Val>;110}111impl<T> IntoUntypedResult for T112where113	T: IntoUntyped,114{115	fn into_untyped_result(typed: Self) -> Result<Val> {116		T::into_untyped(typed)117	}118}119120pub trait FromUntyped: Typed {121	fn from_untyped(untyped: Val) -> Result<Self>;122	fn from_lazy_untyped(lazy: Thunk<Val>) -> Result<Self> {123		Self::from_untyped(lazy.evaluate()?)124	}125126	// Whatever caller should use `from_lazy_untyped` instead of `from_untyped` when possible127	fn wants_lazy() -> bool {128		false129	}130}131132impl<T> Typed for Thunk<T>133where134	T: Typed + Trace + Clone,135{136	const TYPE: &'static ComplexValType = &ComplexValType::Lazy(T::TYPE);137}138139#[inline]140fn try_cast_thunk_val<T: 'static>(typed: Thunk<T>) -> Result<Thunk<Val>, Thunk<T>> {141	if TypeId::of::<T>() == TypeId::of::<Val>() {142		// SAFETY: We know that it is exactly the same type, and we discard the original after that143		// to avoid double-free.144		let transmuted = unsafe { transmute::<Thunk<T>, Thunk<Val>>(typed) };145		Ok(transmuted)146	} else {147		Err(typed)148	}149}150impl<T> IntoUntyped for Thunk<T>151where152	T: IntoUntyped + Trace + Clone,153{154	#[inline]155	fn into_untyped(typed: Self) -> Result<Val> {156		T::into_untyped(typed.evaluate()?)157	}158	fn provides_lazy() -> bool {159		true160	}161162	fn into_lazy_untyped(inner: Self) -> Thunk<Val> {163		// Avoid lazy mapping164		let inner = match try_cast_thunk_val(inner) {165			Ok(v) => return v,166			Err(e) => e,167		};168		inner.map(<ThunkIntoUntyped<T>>::default())169	}170}171impl<T> IntoUntyped for &Thunk<T>172where173	T: IntoUntyped + Trace + Clone,174{175	fn into_untyped(typed: Self) -> Result<Val> {176		T::into_untyped(typed.evaluate()?)177	}178	fn provides_lazy() -> bool {179		true180	}181182	fn into_lazy_untyped(inner: Self) -> Thunk<Val> {183		// Avoid lazy mapping184		let inner = match try_cast_thunk_val(inner.clone()) {185			Ok(v) => return v,186			Err(e) => e,187		};188		inner.map(<ThunkIntoUntyped<T>>::default())189	}190}191192#[inline]193fn try_cast_thunk_t<T: 'static>(typed: Thunk<Val>) -> Result<Thunk<T>, Thunk<Val>> {194	if TypeId::of::<T>() == TypeId::of::<Val>() {195		// SAFETY: We know that it is exactly the same type, and we discard the original after that196		// to avoid double-free.197		let transmuted = unsafe { transmute::<Thunk<Val>, Thunk<T>>(typed) };198		Ok(transmuted)199	} else {200		Err(typed)201	}202}203impl<T> FromUntyped for Thunk<T>204where205	T: Typed + FromUntyped + Trace + Clone,206{207	fn from_untyped(untyped: Val) -> Result<Self> {208		Self::from_lazy_untyped(Thunk::evaluated(untyped))209	}210211	fn wants_lazy() -> bool {212		true213	}214215	fn from_lazy_untyped(inner: Thunk<Val>) -> Result<Self> {216		// Avoid lazy mapping217		let inner = match try_cast_thunk_t(inner) {218			Ok(v) => return Ok(v),219			Err(e) => e,220		};221		Ok(inner.map(<ThunkFromUntyped<T>>::default()))222	}223}224225macro_rules! impl_int {226	($($ty:ty)*) => {$(227		impl Typed for $ty {228			const TYPE: &'static ComplexValType =229				&ComplexValType::BoundedNumber(Some(Self::MIN as f64), Some(Self::MAX as f64));230		}231		impl FromUntyped for $ty {232			fn from_untyped(value: Val) -> Result<Self> {233				<Self as Typed>::TYPE.check(&value)?;234				match value {235					Val::Num(n) => {236						let n = n.get();237						#[allow(clippy::float_cmp)]238						if n.trunc() != n {239							bail!(240								"cannot convert number with fractional part to {}",241								stringify!($ty)242							)243						}244						#[allow(clippy::cast_sign_loss, clippy::cast_possible_truncation, reason = "checked by TYPE")]245						Ok(n as Self)246					}247					_ => unreachable!(),248				}249			}250		}251		impl IntoUntyped for &$ty {252			fn into_untyped(value: Self) -> Result<Val> {253				Ok(Val::Num((*value).into()))254			}255		}256		impl IntoUntyped for $ty {257			fn into_untyped(value: Self) -> Result<Val> {258				Ok(Val::Num(value.into()))259			}260		}261	)*};262}263264impl_int!(i8 u8 i16 u16 i32 u32);265266macro_rules! impl_bounded_int {267	($($name:ident = $ty:ty)*) => {$(268		#[derive(Clone, Copy)]269		#[allow(clippy::cast_possible_truncation, reason = "overflow is api misuse")]270		pub struct $name<const MIN: $ty, const MAX: $ty>($ty);271		impl<const MIN: $ty, const MAX: $ty> $name<MIN, MAX> {272			pub const fn new(value: $ty) -> Option<$name<MIN, MAX>> {273				if value >= MIN && value <= MAX {274					Some(Self(value))275				} else {276					None277				}278			}279			pub const fn value(self) -> $ty {280				self.0281			}282		}283		impl<const MIN: $ty, const MAX: $ty> Deref for $name<MIN, MAX> {284			type Target = $ty;285			fn deref(&self) -> &Self::Target {286				&self.0287			}288		}289290		impl<const MIN: $ty, const MAX: $ty> Typed for $name<MIN, MAX> {291			#[allow(clippy::cast_possible_truncation, clippy::cast_precision_loss, reason = "overflow is api misuse")]292			const TYPE: &'static ComplexValType =293				&ComplexValType::BoundedNumber(294					Some(MIN as f64),295					Some(MAX as f64),296				);297		}298299		impl<const MIN: $ty, const MAX: $ty> FromUntyped for $name<MIN, MAX> {300			fn from_untyped(value: Val) -> Result<Self> {301				<Self as Typed>::TYPE.check(&value)?;302				match value {303					Val::Num(n) => {304						let n = n.get();305						#[allow(clippy::float_cmp)]306						if n.trunc() != n {307							bail!(308								"cannot convert number with fractional part to {}",309								stringify!($ty)310							)311						}312						#[allow(clippy::cast_possible_truncation, clippy::cast_sign_loss, reason = "overflow is api misuse, the range is checked by TYPE")]313						Ok(Self(n as $ty))314					}315					_ => unreachable!(),316				}317			}318		}319320		impl<const MIN: $ty, const MAX: $ty> IntoUntyped for $name<MIN, MAX> {321			#[allow(clippy::cast_lossless)]322			fn into_untyped(value: Self) -> Result<Val> {323				Ok(Val::try_num(value.0)?)324			}325		}326	)*};327}328329impl_bounded_int!(330	BoundedI8 = i8331	BoundedI16 = i16332	BoundedI32 = i32333	BoundedI64 = i64334	BoundedUsize = usize335);336337impl Typed for f64 {338	const TYPE: &'static ComplexValType = &ComplexValType::Simple(ValType::Num);339}340impl IntoUntyped for &f64 {341	fn into_untyped(value: Self) -> Result<Val> {342		Ok(Val::try_num(*value)?)343	}344}345impl IntoUntyped for f64 {346	fn into_untyped(value: Self) -> Result<Val> {347		Ok(Val::try_num(value)?)348	}349}350impl FromUntyped for f64 {351	fn from_untyped(value: Val) -> Result<Self> {352		<Self as Typed>::TYPE.check(&value)?;353		match value {354			Val::Num(n) => Ok(n.get()),355			_ => unreachable!(),356		}357	}358}359360pub struct PositiveF64(pub f64);361impl Typed for PositiveF64 {362	const TYPE: &'static ComplexValType = &ComplexValType::BoundedNumber(Some(0.0), None);363}364impl IntoUntyped for &PositiveF64 {365	fn into_untyped(value: Self) -> Result<Val> {366		Ok(Val::try_num(value.0)?)367	}368}369impl FromUntyped for PositiveF64 {370	fn from_untyped(value: Val) -> Result<Self> {371		<Self as Typed>::TYPE.check(&value)?;372		match value {373			Val::Num(n) => Ok(Self(n.get())),374			_ => unreachable!(),375		}376	}377}378impl Typed for usize {379	const TYPE: &'static ComplexValType =380		&ComplexValType::BoundedNumber(Some(0.0), Some(MAX_SAFE_INTEGER));381}382impl IntoUntyped for usize {383	fn into_untyped(value: Self) -> Result<Val> {384		Ok(Val::try_num(value)?)385	}386}387impl FromUntyped for usize {388	fn from_untyped(value: Val) -> Result<Self> {389		<Self as Typed>::TYPE.check(&value)?;390		match value {391			Val::Num(n) => {392				let n = n.get();393				#[allow(clippy::float_cmp)]394				if n.trunc() != n {395					bail!("cannot convert number with fractional part to usize")396				}397				#[allow(398					clippy::cast_possible_truncation,399					clippy::cast_sign_loss,400					reason = "the range is checked by TYPE"401				)]402				Ok(n as Self)403			}404			_ => unreachable!(),405		}406	}407}408409impl Typed for IStr {410	const TYPE: &'static ComplexValType = &ComplexValType::Simple(ValType::Str);411}412impl IntoUntyped for IStr {413	fn into_untyped(value: Self) -> Result<Val> {414		Ok(Val::string(value))415	}416}417impl FromUntyped for IStr {418	fn from_untyped(value: Val) -> Result<Self> {419		<Self as Typed>::TYPE.check(&value)?;420		match value {421			Val::Str(s) => Ok(s.into_flat()),422			_ => unreachable!(),423		}424	}425}426427impl Typed for String {428	const TYPE: &'static ComplexValType = &ComplexValType::Simple(ValType::Str);429}430impl IntoUntyped for String {431	fn into_untyped(value: Self) -> Result<Val> {432		Ok(Val::string(value))433	}434}435impl FromUntyped for String {436	fn from_untyped(value: Val) -> Result<Self> {437		<Self as Typed>::TYPE.check(&value)?;438		match value {439			Val::Str(s) => Ok(s.to_string()),440			_ => unreachable!(),441		}442	}443}444445impl Typed for StrValue {446	const TYPE: &'static ComplexValType = &ComplexValType::Simple(ValType::Str);447}448impl IntoUntyped for StrValue {449	fn into_untyped(value: Self) -> Result<Val> {450		Ok(Val::Str(value))451	}452}453impl FromUntyped for StrValue {454	fn from_untyped(value: Val) -> Result<Self> {455		<Self as Typed>::TYPE.check(&value)?;456		match value {457			Val::Str(s) => Ok(s),458			_ => unreachable!(),459		}460	}461}462463impl Typed for char {464	const TYPE: &'static ComplexValType = &ComplexValType::Char;465}466impl IntoUntyped for &char {467	fn into_untyped(value: Self) -> Result<Val> {468		Ok(Val::string(*value))469	}470}471impl IntoUntyped for char {472	fn into_untyped(value: Self) -> Result<Val> {473		Ok(Val::string(value))474	}475}476impl FromUntyped for char {477	fn from_untyped(value: Val) -> Result<Self> {478		<Self as Typed>::TYPE.check(&value)?;479		match value {480			Val::Str(s) => Ok(s.into_flat().chars().next().unwrap()),481			_ => unreachable!(),482		}483	}484}485486// TODO: View into vec using ArrayLike?487impl<T> Typed for Vec<T>488where489	T: Typed,490{491	const TYPE: &'static ComplexValType = &ComplexValType::ArrayRef(T::TYPE);492}493impl<T: Typed + IntoUntyped> IntoUntyped for Vec<T> {494	fn into_untyped(value: Self) -> Result<Val> {495		Ok(Val::Arr(496			value497				.into_iter()498				.map(T::into_untyped)499				.collect::<Result<ArrValue>>()?,500		))501	}502}503impl<T: Typed + FromUntyped> FromUntyped for Vec<T> {504	fn from_untyped(value: Val) -> Result<Self> {505		let Val::Arr(a) = value else {506			<Self as Typed>::TYPE.check(&value)?;507			unreachable!("typecheck should fail")508		};509		a.iter()510			.enumerate()511			.map(|(i, r)| {512				r.and_then(|t| {513					T::from_untyped(t).with_description(|| format!("parsing elem <{i}>"))514				})515			})516			.collect::<Result<Self>>()517	}518}519520// TODO: View into BTreeMap using ObjectCore?521impl<K, V> Typed for BTreeMap<K, V>522where523	K: Typed + Ord,524	V: Typed,525{526	const TYPE: &'static ComplexValType = &ComplexValType::AttrsOf(V::TYPE);527}528impl<K, V> IntoUntyped for BTreeMap<K, V>529where530	K: Typed + Ord + IntoUntyped,531	V: Typed + IntoUntyped,532{533	fn into_untyped(typed: Self) -> Result<Val> {534		let mut out = ObjValueBuilder::with_capacity(typed.len());535		for (k, v) in typed {536			let Some(key) = K::into_untyped(k)?.as_str() else {537				bail!("map key should serialize to string");538			};539			let value = V::into_untyped(v)?;540			out.field(key).value(value);541		}542		Ok(Val::Obj(out.build()))543	}544}545impl<K, V> FromUntyped for BTreeMap<K, V>546where547	K: FromUntyped + Ord,548	V: FromUntyped,549{550	fn from_untyped(value: Val) -> Result<Self> {551		Self::TYPE.check(&value)?;552		let obj = value.as_obj().expect("typecheck should fail");553554		let mut out = Self::new();555		if V::wants_lazy() {556			for key in obj.fields_ex(557				false,558				#[cfg(feature = "exp-preserve-order")]559				false,560			) {561				let value = obj.get_lazy(key.clone()).expect("field exists");562				let value = V::from_lazy_untyped(value)?;563				let key = K::from_untyped(Val::Str(key.into()))?;564				let _ = out.insert(key, value);565			}566		} else {567			for (key, value) in obj.iter(568				#[cfg(feature = "exp-preserve-order")]569				false,570			) {571				let key = K::from_untyped(Val::Str(key.into()))?;572				let value = V::from_untyped(value?)?;573				let _ = out.insert(key, value);574			}575		}576		Ok(out)577	}578}579580impl Typed for Val {581	const TYPE: &'static ComplexValType = &ComplexValType::Any;582}583impl IntoUntyped for &Val {584	#[inline]585	fn into_untyped(typed: Self) -> Result<Val> {586		Ok(typed.clone())587	}588}589impl IntoUntyped for Val {590	#[inline]591	fn into_untyped(typed: Self) -> Result<Val> {592		Ok(typed)593	}594}595impl FromUntyped for Val {596	fn from_untyped(untyped: Val) -> Result<Self> {597		Ok(untyped)598	}599}600601#[doc(hidden)]602impl<T> Typed for Result<T>603where604	T: Typed,605{606	const TYPE: &'static ComplexValType = &ComplexValType::Any;607}608impl<T: IntoUntyped> IntoUntypedResult for Result<T> {609	fn into_untyped_result(typed: Self) -> Result<Val> {610		typed.map(T::into_untyped)?611	}612}613614/// Specialization615impl Typed for IBytes {616	const TYPE: &'static ComplexValType =617		&ComplexValType::ArrayRef(&ComplexValType::BoundedNumber(Some(0.0), Some(255.0)));618}619impl IntoUntyped for &IBytes {620	fn into_untyped(value: Self) -> Result<Val> {621		Ok(Val::arr(value.clone()))622	}623}624impl IntoUntyped for IBytes {625	fn into_untyped(value: Self) -> Result<Val> {626		Ok(Val::arr(value))627	}628}629impl FromUntyped for IBytes {630	fn from_untyped(value: Val) -> Result<Self> {631		let Val::Arr(a) = &value else {632			<Self as Typed>::TYPE.check(&value)?;633			unreachable!()634		};635		if let Some(bytes) = a.as_any().downcast_ref::<IBytes>() {636			return Ok(bytes.clone());637		}638		<Self as Typed>::TYPE.check(&value)?;639		// Any::downcast_ref::<ByteArray>(&a);640		let mut out = Vec::with_capacity(a.len());641		for e in a.iter() {642			let r = e?;643			out.push(u8::from_untyped(r)?);644		}645		Ok(out.as_slice().into())646	}647}648649pub struct M1;650impl Typed for M1 {651	const TYPE: &'static ComplexValType = &ComplexValType::BoundedNumber(Some(-1.0), Some(-1.0));652}653impl IntoUntyped for &M1 {654	fn into_untyped(_: Self) -> Result<Val> {655		Ok(Val::Num(NumValue::new(-1.0).expect("finite")))656	}657}658impl FromUntyped for M1 {659	fn from_untyped(value: Val) -> Result<Self> {660		<Self as Typed>::TYPE.check(&value)?;661		Ok(Self)662	}663}664665macro_rules! decl_either {666	($($name: ident, $($id: ident)*);*) => {$(667		#[derive(Clone)]668		pub enum $name<$($id),*> {669			$($id($id)),*670		}671		impl<$($id),*> Typed for $name<$($id),*>672		where673			$($id: Typed,)*674		{675			const TYPE: &'static ComplexValType = &ComplexValType::UnionRef(&[$($id::TYPE),*]);676		}677		impl<$($id),*> IntoUntyped for $name<$($id),*>678		where679			$($id: Typed + IntoUntyped,)*680		{681			fn into_untyped(value: Self) -> Result<Val> {682				match value {$(683					$name::$id(v) => $id::into_untyped(v)684				),*}685			}686		}687688		impl<$($id),*> FromUntyped for $name<$($id),*>689		where690			$($id: Typed + FromUntyped,)*691		{692			fn from_untyped(value: Val) -> Result<Self> {693				$(694					if $id::TYPE.check(&value).is_ok() {695						$id::from_untyped(value).map(Self::$id)696					} else697				)* {698					<Self as Typed>::TYPE.check(&value)?;699					unreachable!()700				}701			}702		}703	)*}704}705decl_either!(706	Either1, A;707	Either2, A B;708	Either3, A B C;709	Either4, A B C D;710	Either5, A B C D E;711	Either6, A B C D E F;712	Either7, A B C D E F G713);714#[macro_export]715macro_rules! Either {716	($a:ty) => {$crate::typed::Either1<$a>};717	($a:ty, $b:ty) => {$crate::typed::Either2<$a, $b>};718	($a:ty, $b:ty, $c:ty) => {$crate::typed::Either3<$a, $b, $c>};719	($a:ty, $b:ty, $c:ty, $d:ty) => {$crate::typed::Either4<$a, $b, $c, $d>};720	($a:ty, $b:ty, $c:ty, $d:ty, $e:ty) => {$crate::typed::Either5<$a, $b, $c, $d, $e>};721	($a:ty, $b:ty, $c:ty, $d:ty, $e:ty, $f:ty) => {$crate::typed::Either6<$a, $b, $c, $d, $e, $f>};722	($a:ty, $b:ty, $c:ty, $d:ty, $e:ty, $f:ty, $g:ty) => {$crate::typed::Either7<$a, $b, $c, $d, $e, $f, $g>};723}724pub use Either;725726pub type MyType = Either![u32, f64, String];727728impl Typed for ArrValue {729	const TYPE: &'static ComplexValType = &ComplexValType::Simple(ValType::Arr);730}731impl IntoUntyped for ArrValue {732	fn into_untyped(value: Self) -> Result<Val> {733		Ok(Val::Arr(value))734	}735}736impl FromUntyped for ArrValue {737	fn from_untyped(value: Val) -> Result<Self> {738		<Self as Typed>::TYPE.check(&value)?;739		match value {740			Val::Arr(a) => Ok(a),741			_ => unreachable!(),742		}743	}744}745746impl Typed for FuncVal {747	const TYPE: &'static ComplexValType = &ComplexValType::Simple(ValType::Func);748}749impl IntoUntyped for FuncVal {750	fn into_untyped(value: Self) -> Result<Val> {751		Ok(Val::Func(value))752	}753}754impl FromUntyped for FuncVal {755	fn from_untyped(value: Val) -> Result<Self> {756		<Self as Typed>::TYPE.check(&value)?;757		match value {758			Val::Func(a) => Ok(a),759			_ => unreachable!(),760		}761	}762}763764impl Typed for ObjValue {765	const TYPE: &'static ComplexValType = &ComplexValType::Simple(ValType::Obj);766}767impl IntoUntyped for ObjValue {768	fn into_untyped(value: Self) -> Result<Val> {769		Ok(Val::Obj(value))770	}771}772impl FromUntyped for ObjValue {773	fn from_untyped(value: Val) -> Result<Self> {774		<Self as Typed>::TYPE.check(&value)?;775		match value {776			Val::Obj(a) => Ok(a),777			_ => unreachable!(),778		}779	}780}781782impl Typed for bool {783	const TYPE: &'static ComplexValType = &ComplexValType::Simple(ValType::Bool);784}785impl IntoUntyped for &bool {786	fn into_untyped(value: Self) -> Result<Val> {787		Ok(Val::Bool(*value))788	}789}790impl IntoUntyped for bool {791	fn into_untyped(value: Self) -> Result<Val> {792		Ok(Val::Bool(value))793	}794}795impl FromUntyped for bool {796	fn from_untyped(value: Val) -> Result<Self> {797		<Self as Typed>::TYPE.check(&value)?;798		match value {799			Val::Bool(a) => Ok(a),800			_ => unreachable!(),801		}802	}803}804805impl Typed for IndexableVal {806	const TYPE: &'static ComplexValType = &ComplexValType::UnionRef(&[807		&ComplexValType::Simple(ValType::Arr),808		&ComplexValType::Simple(ValType::Str),809	]);810}811impl IntoUntyped for IndexableVal {812	fn into_untyped(value: Self) -> Result<Val> {813		match value {814			Self::Str(s) => Ok(Val::string(s)),815			Self::Arr(a) => Ok(Val::Arr(a)),816		}817	}818}819impl FromUntyped for IndexableVal {820	fn from_untyped(value: Val) -> Result<Self> {821		<Self as Typed>::TYPE.check(&value)?;822		value.into_indexable()823	}824}825826impl Typed for () {827	const TYPE: &'static ComplexValType = &ComplexValType::Simple(ValType::Null);828}829impl IntoUntyped for &() {830	fn into_untyped((): Self) -> Result<Val> {831		Ok(Val::Null)832	}833}834impl IntoUntyped for () {835	fn into_untyped((): Self) -> Result<Val> {836		Ok(Val::Null)837	}838}839impl FromUntyped for () {840	fn from_untyped(value: Val) -> Result<Self> {841		<Self as Typed>::TYPE.check(&value)?;842		Ok(())843	}844}845846impl<T> Typed for Option<T>847where848	T: Typed,849{850	const TYPE: &'static ComplexValType =851		&ComplexValType::UnionRef(&[&ComplexValType::Simple(ValType::Null), T::TYPE]);852}853impl<T> IntoUntyped for Option<T>854where855	T: Typed + IntoUntyped,856{857	fn into_untyped(typed: Self) -> Result<Val> {858		typed.map_or_else(|| Ok(Val::Null), |v| T::into_untyped(v))859	}860}861impl<T> FromUntyped for Option<T>862where863	T: Typed + FromUntyped,864{865	fn from_untyped(untyped: Val) -> Result<Self> {866		if matches!(untyped, Val::Null) {867			Ok(None)868		} else {869			T::from_untyped(untyped).map(Some)870		}871	}872}873874impl Typed for NumValue {875	const TYPE: &'static ComplexValType = &ComplexValType::Simple(ValType::Num);876}877impl IntoUntyped for &NumValue {878	fn into_untyped(typed: Self) -> Result<Val> {879		Ok(Val::Num(*typed))880	}881}882impl FromUntyped for NumValue {883	fn from_untyped(untyped: Val) -> Result<Self> {884		Self::TYPE.check(&untyped)?;885		match untyped {886			Val::Num(v) => Ok(v),887			_ => unreachable!(),888		}889	}890}
modifiedcrates/jrsonnet-evaluator/src/val.rsdiffbeforeafterboth
--- a/crates/jrsonnet-evaluator/src/val.rs
+++ b/crates/jrsonnet-evaluator/src/val.rs
@@ -5,7 +5,6 @@
 	marker::PhantomData,
 	mem::replace,
 	num::NonZeroU32,
-	ops::Deref,
 	rc::Rc,
 };
 
@@ -14,16 +13,15 @@
 pub use jrsonnet_macros::Thunk;
 use jrsonnet_types::ValType;
 use rustc_hash::FxHashMap;
-use thiserror::Error;
 
 pub use crate::arr::{ArrValue, ArrayLike};
 use crate::{
-	ObjValue, Result, SupThis, Unbound, WeakSupThis, bail,
+	NumValue, ObjValue, Result, SupThis, Unbound, WeakSupThis, bail,
 	error::{Error, ErrorKind::*},
 	function::FuncVal,
 	gc::WithCapacityExt as _,
 	manifest::{ManifestFormat, ToStringFormat},
-	typed::{BoundedUsize, MAX_SAFE_INTEGER, MIN_SAFE_INTEGER},
+	typed::BoundedUsize,
 };
 
 pub trait ThunkValue: Trace {
@@ -439,134 +437,6 @@
 		let a = self.clone().into_flat();
 		let b = other.clone().into_flat();
 		a.cmp(&b)
-	}
-}
-
-/// Represents jsonnet number
-/// Jsonnet numbers are finite f64, with NaNs disallowed
-#[derive(Trace, Clone, Copy)]
-#[repr(transparent)]
-pub struct NumValue(f64);
-impl NumValue {
-	/// Creates a [`NumValue`], if value is finite and not NaN
-	pub fn new(v: f64) -> Option<Self> {
-		if !v.is_finite() {
-			return None;
-		}
-		Some(Self(v))
-	}
-	#[inline]
-	pub const fn get(&self) -> f64 {
-		self.0
-	}
-	pub(crate) fn truncate_for_bitwise(self) -> Result<i64> {
-		if self.0 < MIN_SAFE_INTEGER || self.0 > MAX_SAFE_INTEGER {
-			bail!("numberic value outside of safe integer range for bitwise operation");
-		}
-		#[expect(clippy::cast_possible_truncation, reason = "intended")]
-		Ok(self.0 as i64)
-	}
-}
-impl PartialEq for NumValue {
-	fn eq(&self, other: &Self) -> bool {
-		self.0 == other.0
-	}
-}
-impl Eq for NumValue {}
-impl Ord for NumValue {
-	#[inline]
-	fn cmp(&self, other: &Self) -> Ordering {
-		// Can't use `total_cmp`: its behavior for `-0` and `0`
-		// is not following wanted.
-		unsafe { self.0.partial_cmp(&other.0).unwrap_unchecked() }
-	}
-}
-impl PartialOrd for NumValue {
-	#[inline]
-	fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
-		Some(self.cmp(other))
-	}
-}
-impl Debug for NumValue {
-	fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
-		Debug::fmt(&self.0, f)
-	}
-}
-impl Display for NumValue {
-	fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
-		Display::fmt(&self.0, f)
-	}
-}
-impl Deref for NumValue {
-	type Target = f64;
-
-	#[inline]
-	fn deref(&self) -> &Self::Target {
-		&self.0
-	}
-}
-macro_rules! impl_num {
-	($($ty:ty),+) => {$(
-		impl From<$ty> for NumValue {
-			#[inline]
-			fn from(value: $ty) -> Self {
-				Self(value.into())
-			}
-		}
-	)+};
-}
-impl_num!(i8, u8, i16, u16, i32, u32);
-
-#[derive(Clone, Copy, Debug, Error, Trace)]
-pub enum ConvertNumValueError {
-	#[error("overflow")]
-	Overflow,
-	#[error("underflow")]
-	Underflow,
-	#[error("non-finite")]
-	NonFinite,
-}
-impl From<ConvertNumValueError> for Error {
-	fn from(e: ConvertNumValueError) -> Self {
-		Self::new(e.into())
-	}
-}
-
-macro_rules! impl_try_num {
-	($($ty:ty),+) => {$(
-		impl TryFrom<$ty> for NumValue {
-			type Error = ConvertNumValueError;
-			#[inline]
-			fn try_from(value: $ty) -> Result<Self, ConvertNumValueError> {
-				#[expect(clippy::cast_precision_loss, reason = "precision loss is explicitly handled")]
-				let value = value as f64;
-				if value < MIN_SAFE_INTEGER {
-					return Err(ConvertNumValueError::Underflow)
-				} else if value > MAX_SAFE_INTEGER {
-					return Err(ConvertNumValueError::Overflow)
-				}
-				// Number is finite.
-				Ok(Self(value))
-			}
-		}
-	)+};
-}
-impl_try_num!(usize, isize, i64, u64);
-
-impl TryFrom<f64> for NumValue {
-	type Error = ConvertNumValueError;
-
-	#[inline]
-	fn try_from(value: f64) -> Result<Self, Self::Error> {
-		Self::new(value).ok_or(ConvertNumValueError::NonFinite)
-	}
-}
-impl TryFrom<f32> for NumValue {
-	type Error = ConvertNumValueError;
-
-	#[inline]
-	fn try_from(value: f32) -> Result<Self, Self::Error> {
-		Self::new(f64::from(value)).ok_or(ConvertNumValueError::NonFinite)
 	}
 }
 
modifiedcrates/jrsonnet-ir-parser/src/lib.rsdiffbeforeafterboth
--- a/crates/jrsonnet-ir-parser/src/lib.rs
+++ b/crates/jrsonnet-ir-parser/src/lib.rs
@@ -4,8 +4,8 @@
 use jrsonnet_ir::{
 	ArgsDesc, AssertExpr, AssertStmt, BinaryOp, BinaryOpType, BindSpec, CompSpec, Destruct, Expr,
 	ExprParam, ExprParams, FieldMember, FieldName, ForSpecData, IStr, IfElse, IfSpecData,
-	ImportKind, IndexPart, LiteralType, Member, ObjBody, ObjComp, ObjMembers, Slice, SliceDesc,
-	Source, Span, Spanned, UnaryOpType, Visibility, unescape,
+	ImportKind, IndexPart, LiteralType, Member, NumValue, ObjBody, ObjComp, ObjMembers, Slice,
+	SliceDesc, Source, Span, Spanned, UnaryOpType, Visibility, unescape,
 };
 use jrsonnet_lexer::{Lexeme, Lexer, Span as LexSpan, SyntaxKind, T, collect_lexed_str_block};
 
@@ -202,17 +202,21 @@
 	)
 }
 
-fn parse_number(p: &mut Parser<'_>) -> Result<f64> {
+fn parse_number(p: &mut Parser<'_>) -> Result<NumValue> {
 	let text = p.text();
 	let n: f64 = text
 		.replace('_', "")
 		.parse()
 		.map_err(|_| p.error(format!("invalid number literal: {text}")))?;
-	if !n.is_finite() {
-		return Err(p.error("numbers are finite".into()));
-	}
+
+	let v = match NumValue::try_from(n) {
+		Ok(v) => v,
+		Err(e) => return Err(p.error(format!("invalid number value: {e}"))),
+	};
+
 	p.eat_any();
-	Ok(n)
+
+	Ok(v)
 }
 
 fn ident(p: &mut Parser<'_>) -> Result<IStr> {
modifiedcrates/jrsonnet-ir/Cargo.tomldiffbeforeafterboth
--- a/crates/jrsonnet-ir/Cargo.toml
+++ b/crates/jrsonnet-ir/Cargo.toml
@@ -19,6 +19,7 @@
 static_assertions.workspace = true
 
 peg.workspace = true
+thiserror.workspace = true
 
 [dev-dependencies]
 insta.workspace = true
modifiedcrates/jrsonnet-ir/src/expr.rsdiffbeforeafterboth
--- a/crates/jrsonnet-ir/src/expr.rs
+++ b/crates/jrsonnet-ir/src/expr.rs
@@ -8,6 +8,7 @@
 use jrsonnet_interner::IStr;
 
 use crate::{
+	NumValue,
 	function::{FunctionSignature, ParamDefault, ParamName, ParamParse},
 	source::Source,
 };
@@ -398,7 +399,7 @@
 	/// String value: "hello"
 	Str(IStr),
 	/// Number: 1, 2.0, 2e+20
-	Num(f64),
+	Num(NumValue),
 	/// Variable name: test
 	Var(Spanned<IStr>),
 
modifiedcrates/jrsonnet-ir/src/lib.rsdiffbeforeafterboth
--- a/crates/jrsonnet-ir/src/lib.rs
+++ b/crates/jrsonnet-ir/src/lib.rs
@@ -1,7 +1,10 @@
 #![allow(clippy::redundant_closure_call, clippy::derive_partial_eq_without_eq)]
 
 mod expr;
+use std::{cmp::Ordering, fmt, ops::Deref};
+
 pub use expr::*;
+use jrsonnet_gcmodule::Acyclic;
 pub use jrsonnet_interner::IStr;
 pub mod function;
 mod location;
@@ -14,3 +17,134 @@
 	Source, SourceDefaultIgnoreJpath, SourceDirectory, SourceFifo, SourceFile, SourcePath,
 	SourcePathT, SourceVirtual,
 };
+
+// It seels to be a wrong place for this kind of stuff, but as it would also be used for static analysis and
+// is already wanted for NumValue, I don't know a better place.
+#[expect(clippy::cast_precision_loss, reason = "checked to not overflow")]
+pub const MAX_SAFE_INTEGER: f64 = ((1u64 << (f64::MANTISSA_DIGITS)) - 1) as f64;
+#[expect(clippy::cast_precision_loss, reason = "checked to not overflow")]
+pub const MIN_SAFE_INTEGER: f64 = (-((1i64 << (f64::MANTISSA_DIGITS)) - 1)) as f64;
+
+/// Represents jsonnet number
+/// Jsonnet numbers are finite f64, with NaNs disallowed
+#[derive(Acyclic, Clone, Copy)]
+pub struct NumValue(f64);
+impl NumValue {
+	/// Creates a [`NumValue`], if value is finite and not NaN
+	pub fn new(v: f64) -> Option<Self> {
+		if !v.is_finite() {
+			return None;
+		}
+		Some(Self(v))
+	}
+	#[inline]
+	pub const fn get(&self) -> f64 {
+		self.0
+	}
+	pub fn truncate_for_bitwise(self) -> Result<i64, ConvertNumValueError> {
+		if self.0 < MIN_SAFE_INTEGER || self.0 > MAX_SAFE_INTEGER {
+			return Err(ConvertNumValueError::BitwiseSafeRange);
+		}
+		#[expect(clippy::cast_possible_truncation, reason = "intended")]
+		Ok(self.0 as i64)
+	}
+}
+impl PartialEq for NumValue {
+	fn eq(&self, other: &Self) -> bool {
+		self.0 == other.0
+	}
+}
+impl Eq for NumValue {}
+impl Ord for NumValue {
+	#[inline]
+	fn cmp(&self, other: &Self) -> Ordering {
+		// Can't use `total_cmp`: its behavior for `-0` and `0`
+		// is not following wanted.
+		unsafe { self.0.partial_cmp(&other.0).unwrap_unchecked() }
+	}
+}
+impl PartialOrd for NumValue {
+	#[inline]
+	fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
+		Some(self.cmp(other))
+	}
+}
+impl fmt::Debug for NumValue {
+	fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+		fmt::Debug::fmt(&self.0, f)
+	}
+}
+impl fmt::Display for NumValue {
+	fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+		fmt::Display::fmt(&self.0, f)
+	}
+}
+impl Deref for NumValue {
+	type Target = f64;
+
+	#[inline]
+	fn deref(&self) -> &Self::Target {
+		&self.0
+	}
+}
+macro_rules! impl_num {
+	($($ty:ty),+) => {$(
+		impl From<$ty> for NumValue {
+			#[inline]
+			fn from(value: $ty) -> Self {
+				Self(value.into())
+			}
+		}
+	)+};
+}
+impl_num!(i8, u8, i16, u16, i32, u32);
+
+#[derive(Clone, Copy, Debug, thiserror::Error, Acyclic)]
+pub enum ConvertNumValueError {
+	#[error("overflow")]
+	Overflow,
+	#[error("underflow")]
+	Underflow,
+	#[error("non-finite")]
+	NonFinite,
+	#[error("float out of safe int range")]
+	BitwiseSafeRange,
+}
+
+macro_rules! impl_try_num {
+	($($ty:ty),+) => {$(
+		impl TryFrom<$ty> for NumValue {
+			type Error = ConvertNumValueError;
+			#[inline]
+			fn try_from(value: $ty) -> Result<Self, ConvertNumValueError> {
+				#[expect(clippy::cast_precision_loss, reason = "precision loss is explicitly handled")]
+				let value = value as f64;
+				if value < MIN_SAFE_INTEGER {
+					return Err(ConvertNumValueError::Underflow)
+				} else if value > MAX_SAFE_INTEGER {
+					return Err(ConvertNumValueError::Overflow)
+				}
+				// Number is finite.
+				Ok(Self(value))
+			}
+		}
+	)+};
+}
+impl_try_num!(usize, isize, i64, u64);
+
+impl TryFrom<f64> for NumValue {
+	type Error = ConvertNumValueError;
+
+	#[inline]
+	fn try_from(value: f64) -> Result<Self, Self::Error> {
+		Self::new(value).ok_or(ConvertNumValueError::NonFinite)
+	}
+}
+impl TryFrom<f32> for NumValue {
+	type Error = ConvertNumValueError;
+
+	#[inline]
+	fn try_from(value: f32) -> Result<Self, Self::Error> {
+		Self::new(f64::from(value)).ok_or(ConvertNumValueError::NonFinite)
+	}
+}
modifiedcrates/jrsonnet-peg-parser/src/lib.rsdiffbeforeafterboth
--- a/crates/jrsonnet-peg-parser/src/lib.rs
+++ b/crates/jrsonnet-peg-parser/src/lib.rs
@@ -4,8 +4,8 @@
 use jrsonnet_ir::{
 	ArgsDesc, AssertExpr, AssertStmt, BinaryOp, BindSpec, CompSpec, Destruct, DestructRest, Expr,
 	ExprParam, ExprParams, FieldMember, FieldName, ForSpecData, IStr, IfElse, IfSpecData,
-	ImportKind, IndexPart, LiteralType, Member, ObjBody, ObjComp, ObjMembers, Slice, SliceDesc,
-	Source, Span, Spanned, Visibility, unescape,
+	ImportKind, IndexPart, LiteralType, Member, NumValue, ObjBody, ObjComp, ObjMembers, Slice,
+	SliceDesc, Source, Span, Spanned, Visibility, unescape,
 };
 use peg::parser;
 
@@ -52,7 +52,7 @@
 		/// Sequence of digits
 		rule uint_str() -> &'input str = a:$(digit()+ ("_" digit()+)*) { a }
 		/// Number in scientific notation format
-		rule number() -> f64 = quiet!{a:$(uint_str() ("." uint_str())? (['e'|'E'] (s:['+'|'-'])? uint_str())?) {? a.replace("_","").parse().map_err(|_| "<number>") }} / expected!("<number>")
+		rule number() -> f64 = quiet!{a:$(uint_str() ("." uint_str())? (['e'|'E'] (s:['+'|'-'])? uint_str())?) {? a.replace('_',"").parse().map_err(|_| "<number>") }} / expected!("<number>")
 
 		/// Reserved word followed by any non-alphanumberic
 		rule reserved() = ("assert" / "else" / "error" / "false" / "for" / "function" / "if" / "import" / "importstr" / "importbin" / "in" / "local" / "null" / "tailstrict" / "then" / "self" / "super" / "true") end_of_ident()
@@ -267,7 +267,7 @@
 				Expr::ArrComp(Rc::new(expr), specs)
 			}
 		pub rule number_expr(s: &ParserSettings) -> Expr
-			= n:number() {? if n.is_finite() {
+			= n:number() {? if let Some(n) = NumValue::new(n) {
 				Ok(Expr::Num(n))
 			} else {
 				Err("!!!numbers are finite")
modifiedcrates/jrsonnet-stdlib/src/lib.rsdiffbeforeafterboth
--- a/crates/jrsonnet-stdlib/src/lib.rs
+++ b/crates/jrsonnet-stdlib/src/lib.rs
@@ -12,13 +12,12 @@
 pub use encoding::*;
 pub use hash::*;
 use jrsonnet_evaluator::{
-	ContextBuilder, IStr, ObjValue, ObjValueBuilder, Thunk, Val,
+	ContextBuilder, IStr, NumValue, ObjValue, ObjValueBuilder, Thunk, Val,
 	error::Result,
 	function::{CallLocation, FuncVal, builtin_id},
 	tla::TlaArg,
 	trace::PathResolver,
 	typed::SerializeTypedObj as _,
-	val::NumValue,
 };
 use jrsonnet_gcmodule::{Acyclic, Cc, Trace};
 use jrsonnet_ir::Source;
modifiedcrates/jrsonnet-stdlib/src/operator.rsdiffbeforeafterboth
--- a/crates/jrsonnet-stdlib/src/operator.rs
+++ b/crates/jrsonnet-stdlib/src/operator.rs
@@ -2,12 +2,12 @@
 //! However, in our case we instead implement them in native, and implement native functions on top of core for backwards compatibility
 
 use jrsonnet_evaluator::{
-	IStr, Result, Val,
+	IStr, NumValue, Result, Val,
 	function::builtin,
 	operator::evaluate_mod_op,
 	stdlib::std_format,
 	typed::{Either, Either2},
-	val::{NumValue, equals, primitive_equals},
+	val::{equals, primitive_equals},
 };
 
 #[builtin]