1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

checker: check array literal modify error (#9243)

This commit is contained in:
yuyi
2021-03-11 20:57:04 +08:00
committed by GitHub
parent f69cef397c
commit a547e889af
5 changed files with 21 additions and 2 deletions

View File

@@ -59,7 +59,7 @@ const (
// MT19937RNG is generator that uses the Mersenne Twister algorithm with period 2^19937.
pub struct MT19937RNG {
mut:
state []u64 = calculate_state(seed.time_seed_array(2), mut []u64{len: mt19937.nn})
state []u64 = []u64{len: mt19937.nn}
mti int = mt19937.nn
next_rnd u32
has_next bool
@@ -83,6 +83,8 @@ pub fn (mut rng MT19937RNG) seed(seed_data []u32) {
eprintln('mt19937 needs only two 32bit integers as seed: [lower, higher]')
exit(1)
}
// calculate 2 times because MT19937RNG init didn't call calculate_state.
rng.state = calculate_state(seed_data, mut rng.state)
rng.state = calculate_state(seed_data, mut rng.state)
rng.mti = mt19937.nn
rng.next_rnd = 0