Skip to content

math.randomseed with two arguments fails on 32-bit targets (wasm32)#142

Open
evrimoztamur wants to merge 1 commit intokyren:masterfrom
evrimoztamur:master
Open

math.randomseed with two arguments fails on 32-bit targets (wasm32)#142
evrimoztamur wants to merge 1 commit intokyren:masterfrom
evrimoztamur:master

Conversation

@evrimoztamur
Copy link
Copy Markdown

@evrimoztamur evrimoztamur commented Mar 28, 2026

In src/stdlib/math.rs:340, the seed array is hardcoded as [u8; 32]:

let seed: [u8; 32] = core::array::from_fn(|idx| { ... });

On 32-bit targets (e.g. wasm32-unknown-unknown), SmallRng is Xoshiro128PlusPlus
with a 16-byte seed, so SmallRng::from_seed(seed) fails to compile:

expected an array with a size of 16, found one with a size of 32

Fix: replace the hardcoded size with the associated type:

let seed: <SmallRng as SeedableRng>::Seed = core::array::from_fn(|idx| { ... });

@evrimoztamur evrimoztamur changed the title Replace SmallRng seed type math.randomseed with two arguments fails on 32-bit targets (wasm32) Mar 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant