diff --git a/vlib/rand/rand.v b/vlib/rand/rand.v index 974dfadb76..aa56a0c27a 100644 --- a/vlib/rand/rand.v +++ b/vlib/rand/rand.v @@ -1,6 +1,7 @@ // Copyright (c) 2019-2021 Alexander Medvednikov. All rights reserved. // Use of this source code is governed by an MIT license // that can be found in the LICENSE file. +[has_globals] module rand import rand.config @@ -35,9 +36,7 @@ mut: free() } -__global ( - default_rng &PRNG -) +__global default_rng &PRNG // new_default returns a new instance of the default RNG. If the seed is not provided, the current time will be used to seed the instance. [manualfree] diff --git a/vlib/rand/splitmix64/splitmix64.v b/vlib/rand/splitmix64/splitmix64.v index 663b9380bc..6452cbd4a8 100644 --- a/vlib/rand/splitmix64/splitmix64.v +++ b/vlib/rand/splitmix64/splitmix64.v @@ -45,8 +45,8 @@ pub fn (mut rng SplitMix64RNG) u32() u32 { pub fn (mut rng SplitMix64RNG) u64() u64 { rng.state += (0x9e3779b97f4a7c15) mut z := rng.state - z = (z ^ ((z >> u64(30)))) * (0xbf58476d1ce4e5b9) - z = (z ^ ((z >> u64(27)))) * (0x94d049bb133111eb) + z = (z ^ (z >> u64(30))) * 0xbf58476d1ce4e5b9 + z = (z ^ (z >> u64(27))) * 0x94d049bb133111eb return z ^ (z >> (31)) } diff --git a/vlib/sokol/sapp/sapp.c.v b/vlib/sokol/sapp/sapp.c.v index 1cb482a4b0..abcc8ed2a3 100644 --- a/vlib/sokol/sapp/sapp.c.v +++ b/vlib/sokol/sapp/sapp.c.v @@ -1,3 +1,4 @@ +[has_globals] module sapp import sokol.gfx @@ -5,9 +6,7 @@ import sokol.gfx pub const used_import = gfx.used_import // Android needs a global reference to `g_desc` -__global ( - g_desc C.sapp_desc -) +__global g_desc C.sapp_desc pub fn create_desc() C.sg_desc { metal_desc := C.sg_metal_context_desc{ diff --git a/vlib/v/parser/parser.v b/vlib/v/parser/parser.v index 638bbbf8d8..572aa61c23 100644 --- a/vlib/v/parser/parser.v +++ b/vlib/v/parser/parser.v @@ -3074,14 +3074,10 @@ fn (mut p Parser) return_stmt() ast.Return { } } -// TODO: remove this whitelist of modules which allow globals by default -const global_enabled_mods = ['rand', 'sokol.sapp'] - // left hand side of `=` or `:=` in `a,b,c := 1,2,3` fn (mut p Parser) global_decl() ast.GlobalDecl { if !p.has_globals && !p.pref.enable_globals && !p.pref.is_fmt && !p.pref.translated - && !p.pref.is_livemain && !p.pref.building_v && !p.builtin_mod - && p.mod !in parser.global_enabled_mods { + && !p.pref.is_livemain && !p.pref.building_v && !p.builtin_mod { p.error('use `v -enable-globals ...` to enable globals') return ast.GlobalDecl{} }