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

v: replace --enable-globals with -enable-globals (#9898)

This commit is contained in:
Enzo 2021-04-28 06:44:28 +02:00 committed by GitHub
parent a2014f86b7
commit 4f246222b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 11 additions and 7 deletions

View File

@ -196,7 +196,7 @@ files with compilation errors.
- `os.cp()` for copying files and directores.
- Additional compile-time flags: `$if clang, msvc, mingw, x32, x64, big_endian, little_endian {`.
- All C functions now have to be declared, all missing C functions have been defined.
- Global variables (only with the `--enable-globals` flag)
- Global variables (only with the `-enable-globals` flag)
for low level applications like kernels and drivers.
- Nothing can be cast to bool (previously code like `if bool(1) {` worked).
- `<<` and `>>` now work with all integer types.

View File

@ -1713,7 +1713,7 @@ immutable by default, even when [references](#references) are passed.
V is not a purely functional language however.
There is a compiler flag to enable global variables (`--enable-globals`), but this is
There is a compiler flag to enable global variables (`-enable-globals`), but this is
intended for low-level applications like kernels and drivers.
### Mutable arguments

View File

@ -1,4 +1,4 @@
vlib/v/checker/tests/globals_error.vv:2:1: error: use `v --enable-globals ...` to enable globals
vlib/v/checker/tests/globals_error.vv:2:1: error: use `v -enable-globals ...` to enable globals
1 |
2 | __global ( rfcnt int )
| ~~~~~~~~

View File

@ -75,9 +75,9 @@ fn test_all() {
tasks.add('', parser_dir, '-prod', '.out', parser_tests, false)
tasks.add('', checker_dir, '-prod', '.out', checker_tests, false)
tasks.add('', scanner_dir, '-prod', '.out', scanner_tests, false)
tasks.add('', checker_dir, '--enable-globals run', '.run.out', ['globals_error.vv'],
tasks.add('', checker_dir, '-enable-globals run', '.run.out', ['globals_error.vv'],
false)
tasks.add('', global_dir, '--enable-globals', '.out', global_tests, false)
tasks.add('', global_dir, '-enable-globals', '.out', global_tests, false)
tasks.add('', module_dir, '-prod run', '.out', module_tests, true)
tasks.add('', run_dir, 'run', '.run.out', run_tests, false)
tasks.run()

View File

@ -2806,7 +2806,7 @@ fn (mut p Parser) global_decl() ast.GlobalDecl {
if !p.pref.translated && !p.pref.is_livemain && !p.builtin_mod && !p.pref.building_v
&& p.mod != 'ui' && p.mod != 'gg2' && p.mod != 'uiold' && !p.pref.enable_globals
&& !p.pref.is_fmt && p.mod !in parser.global_enabled_mods {
p.error('use `v --enable-globals ...` to enable globals')
p.error('use `v -enable-globals ...` to enable globals')
return ast.GlobalDecl{}
}
start_pos := p.tok.position()

View File

@ -336,7 +336,11 @@ pub fn parse_args(known_external_commands []string, args []string) (&Preferences
'-shared' {
res.is_shared = true
}
'--enable-globals', '-enable-globals' {
'--enable-globals' {
eprintln('`--enable-globals` flag is deprecated, please use `-enable-globals` instead')
res.enable_globals = true
}
'-enable-globals' {
res.enable_globals = true
}
'-autofree' {