mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
parser: add mod list to allow globals by default
This commit is contained in:
parent
82e6628659
commit
62c80bc2c5
@ -1367,10 +1367,16 @@ fn (mut p Parser) return_stmt() ast.Return {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const(
|
||||||
|
// modules which allow globals by default
|
||||||
|
global_enabled_mods = ['rand']
|
||||||
|
)
|
||||||
|
|
||||||
// left hand side of `=` or `:=` in `a,b,c := 1,2,3`
|
// left hand side of `=` or `:=` in `a,b,c := 1,2,3`
|
||||||
fn (mut p Parser) global_decl() ast.GlobalDecl {
|
fn (mut p Parser) global_decl() ast.GlobalDecl {
|
||||||
if !p.pref.translated && !p.pref.is_livemain && !p.builtin_mod && !p.pref.building_v &&
|
if !p.pref.translated && !p.pref.is_livemain && !p.builtin_mod && !p.pref.building_v &&
|
||||||
p.mod != 'ui' && p.mod != 'gg2' && p.mod != 'uiold' && !os.getwd().contains('/volt') && !p.pref.enable_globals {
|
p.mod != 'ui' && p.mod != 'gg2' && p.mod != 'uiold' && !os.getwd().contains('/volt') &&
|
||||||
|
!p.pref.enable_globals && p.mod !in global_enabled_mods {
|
||||||
p.error('use `v --enable-globals ...` to enable globals')
|
p.error('use `v --enable-globals ...` to enable globals')
|
||||||
}
|
}
|
||||||
start_pos := p.tok.position()
|
start_pos := p.tok.position()
|
||||||
|
Loading…
Reference in New Issue
Block a user