-
Notifications
You must be signed in to change notification settings - Fork 114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
usize
and isize
should be typed as bigint
on 64-bit architectures
#311
Comments
This can be implemented with the following code #[cfg(target_pointer_width = "16")]
impl_primitives! {
usize, isize, NonZeroUsize, NonZeroIsize => "number"
}
#[cfg(target_pointer_width = "32")]
impl_primitives! {
usize, isize, NonZeroUsize, NonZeroIsize => "number"
}
#[cfg(target_pointer_width = "64")]
impl_primitives! {
usize, isize, NonZeroUsize, NonZeroIsize => "bigint"
} But people seem to dislike the use of What do you think @NyxCode? |
Alternatively, we could make a manual // 6 bytes is the most that can be guaranteed to fit a JS Number
if std::mem::size_of::<usize>() <= 6 {
"number"
} else {
"bigint"
}.to_owned() This would handle any weird architechture (I'm decently sure there's nothing with 5 byte pointers, but who knows) |
I do agree that this should be the default though. As #94 (comment) states, "soundness should not be an opt-in", users coercing i/u64, i/u128, i/usize to |
Agreed. The reason I had this issue come was that my rust backend was sending random |
I see, but beware that even if this gets implemented, you still need to customize your (de)serialization logic to produce |
In particular, if you send data to your frontend as JSON, which doesn't support |
This would align with how, for example,
u32
andu64
are currently typed.The text was updated successfully, but these errors were encountered: