From d444f9c25dea51ee70d1a8ec896b34484370e791 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Wed, 22 Apr 2026 03:45:30 +0300 Subject: [PATCH] all: rename make.bat; better dynamic array init syntax --- .github/workflows/cross_ci.yml | 2 +- .github/workflows/debug.yml | 2 +- .../more_extensive_but_slower_tests_ci.yml | 2 +- .github/workflows/paths_ci.yml | 2 +- .github/workflows/periodic_ci.yml | 2 +- .github/workflows/release_ci.yml | 2 +- .github/workflows/sanitized_ci.yml | 2 +- .github/workflows/symlink_ci.yml | 2 +- .github/workflows/time_ci.yml | 2 +- .github/workflows/tools_ci.yml | 2 +- .github/workflows/vpm_ci.yml | 2 +- .github/workflows/wasm_backend_ci.yml | 2 +- .github/workflows/windows_ci_gcc.yml | 2 +- .github/workflows/windows_ci_msvc.yml | 2 +- .github/workflows/windows_ci_tcc.yml | 4 ++-- AGENTS.md | 4 ++-- CONTRIBUTING.md | 2 +- GNUmakefile | 2 +- README.md | 4 ++-- cmd/tools/vsymlink/vsymlink_windows.c.v | 2 +- cmd/tools/vup.v | 4 ++-- doc/docs.md | 2 +- doc/packaging_v_for_distributions.md | 2 +- v_make.bat => makev.bat | 24 +++++++++---------- vlib/os/glob_test.v | 4 ++-- vlib/v/parser/containers.v | 3 +++ vlib/v/parser/expr.v | 4 ++-- vlib/v/parser/parser.v | 1 + vlib/v/tests/builtin_arrays/array_init_test.v | 4 ++-- vlib/v/util/util.v | 4 ++-- 30 files changed, 51 insertions(+), 47 deletions(-) rename v_make.bat => makev.bat (95%) diff --git a/.github/workflows/cross_ci.yml b/.github/workflows/cross_ci.yml index fea4791ae..fecda31c1 100644 --- a/.github/workflows/cross_ci.yml +++ b/.github/workflows/cross_ci.yml @@ -112,7 +112,7 @@ jobs: run: | echo %VFLAGS% echo $VFLAGS - .\make.bat -msvc + .\makev.bat -msvc - name: TODO v_win.c can be compiled and run with -os windows run: | .\v.exe -os windows -cc msvc -showcc -o v2.exe cmd\v diff --git a/.github/workflows/debug.yml b/.github/workflows/debug.yml index 56f66bbaf..0dee28c3e 100644 --- a/.github/workflows/debug.yml +++ b/.github/workflows/debug.yml @@ -14,7 +14,7 @@ jobs: run: | echo %VFLAGS% echo $VFLAGS - .\make.bat -msvc + .\makev.bat -msvc .\v.exe -cflags /WX self - name: Install dependencies run: | diff --git a/.github/workflows/more_extensive_but_slower_tests_ci.yml b/.github/workflows/more_extensive_but_slower_tests_ci.yml index 183a063fd..bf6592365 100644 --- a/.github/workflows/more_extensive_but_slower_tests_ci.yml +++ b/.github/workflows/more_extensive_but_slower_tests_ci.yml @@ -35,7 +35,7 @@ jobs: run: make -j4 && ./v symlink - name: Build V (Windows) if: runner.os == 'Windows' - run: ./make.bat && ./v symlink + run: ./makev.bat && ./v symlink - name: Run additional crypto tests run: | diff --git a/.github/workflows/paths_ci.yml b/.github/workflows/paths_ci.yml index b80ecb27d..c8431075c 100644 --- a/.github/workflows/paths_ci.yml +++ b/.github/workflows/paths_ci.yml @@ -104,7 +104,7 @@ jobs: dir cd 'path with some $punctuation, and some spaces' dir - .\make.bat -tcc + .\makev.bat -tcc - name: v doctor run: | cd 'path with some $punctuation, and some spaces' diff --git a/.github/workflows/periodic_ci.yml b/.github/workflows/periodic_ci.yml index 72c81054a..6efc8325c 100644 --- a/.github/workflows/periodic_ci.yml +++ b/.github/workflows/periodic_ci.yml @@ -35,6 +35,6 @@ jobs: run: make -j4 && ./v -showcc -o v cmd/v && ./v doctor - name: Build V (Windows) if: runner.os == 'Windows' - run: ./make.bat -msvc && ./v -o v2.exe cmd/v && ./v2 -showcc -o v.exe cmd/v && ./v doctor + run: ./makev.bat -msvc && ./v -o v2.exe cmd/v && ./v2 -showcc -o v.exe cmd/v && ./v doctor - name: Test run: ./v -d network -silent test-self vlib/net diff --git a/.github/workflows/release_ci.yml b/.github/workflows/release_ci.yml index c43b1ca22..17c9d99bc 100644 --- a/.github/workflows/release_ci.yml +++ b/.github/workflows/release_ci.yml @@ -66,7 +66,7 @@ jobs: - name: Compile release binaries (Windows) if: runner.os == 'Windows' run: | - ./make.bat -msvc + ./makev.bat -msvc ./v -prod -cc msvc -o cmd/vprod.exe cmd/v ./v -prod -cc msvc cmd/tools/vup.v ./v -prod -cc msvc cmd/tools/vdoctor.v diff --git a/.github/workflows/sanitized_ci.yml b/.github/workflows/sanitized_ci.yml index a514e720b..ae2ff17bb 100644 --- a/.github/workflows/sanitized_ci.yml +++ b/.github/workflows/sanitized_ci.yml @@ -200,7 +200,7 @@ jobs: run: | echo %VFLAGS% echo $VFLAGS - .\make.bat -msvc + .\makev.bat -msvc .\v.exe self - name: V doctor run: .\v.exe doctor diff --git a/.github/workflows/symlink_ci.yml b/.github/workflows/symlink_ci.yml index dd84aeb95..552504eac 100644 --- a/.github/workflows/symlink_ci.yml +++ b/.github/workflows/symlink_ci.yml @@ -66,7 +66,7 @@ jobs: steps: - uses: actions/checkout@v6 - name: Build V - run: ./make.bat + run: ./makev.bat - name: Symlink run: ./v symlink ${{ matrix.flags }} - name: Check if V is usable diff --git a/.github/workflows/time_ci.yml b/.github/workflows/time_ci.yml index b131afd23..1972c952f 100644 --- a/.github/workflows/time_ci.yml +++ b/.github/workflows/time_ci.yml @@ -58,7 +58,7 @@ jobs: steps: - uses: actions/checkout@v6 - name: Build V - run: .\make.bat + run: .\makev.bat - name: Test time functions in a timezone UTC-12 run: tzutil /s "Dateline Standard Time" && ./v test vlib/time/ - name: Test time functions in a timezone UTC-3 diff --git a/.github/workflows/tools_ci.yml b/.github/workflows/tools_ci.yml index 80c7abbc1..81c37e3ad 100644 --- a/.github/workflows/tools_ci.yml +++ b/.github/workflows/tools_ci.yml @@ -95,7 +95,7 @@ jobs: steps: - uses: actions/checkout@v6 - name: Build V - run: ./make.bat -${{ matrix.cc }} && ./v -o v2.exe cmd/v && ./v2 -showcc -o v.exe cmd/v && ./v symlink && ./v doctor + run: ./makev.bat -${{ matrix.cc }} && ./v -o v2.exe cmd/v && ./v2 -showcc -o v.exe cmd/v && ./v symlink && ./v doctor - name: Install SQLite (needed by vsqlite tool) run: .\.github\workflows\windows-install-sqlite.bat - name: Check build tools diff --git a/.github/workflows/vpm_ci.yml b/.github/workflows/vpm_ci.yml index ec0a10ebf..32e80c406 100644 --- a/.github/workflows/vpm_ci.yml +++ b/.github/workflows/vpm_ci.yml @@ -32,7 +32,7 @@ jobs: run: cd vlang && make -j4 && ./v doctor - name: Build V (Windows) if: runner.os == 'Windows' - run: cd vlang && ./make.bat && ./v doctor + run: cd vlang && ./makev.bat && ./v doctor - name: Cache V uses: actions/cache/save@v5 with: diff --git a/.github/workflows/wasm_backend_ci.yml b/.github/workflows/wasm_backend_ci.yml index ee36aef20..de77a505c 100644 --- a/.github/workflows/wasm_backend_ci.yml +++ b/.github/workflows/wasm_backend_ci.yml @@ -66,7 +66,7 @@ jobs: run: make -j4 - name: Build V (Windows) if: runner.os == 'Windows' - run: ./make.bat + run: ./makev.bat - name: Install WABT to get wasm-decompile if: runner.os != 'Windows' diff --git a/.github/workflows/windows_ci_gcc.yml b/.github/workflows/windows_ci_gcc.yml index 4277f2a02..7ddf74c0d 100644 --- a/.github/workflows/windows_ci_gcc.yml +++ b/.github/workflows/windows_ci_gcc.yml @@ -52,7 +52,7 @@ jobs: dir "c:/Program Files/OpenSSL/lib/VC/x64/" - name: Build run: | - .\make.bat -gcc + .\makev.bat -gcc .\v.exe symlink .\v.exe -stats vlib/crypto/ecdsa/ecdsa_test.v - name: Test v binaries diff --git a/.github/workflows/windows_ci_msvc.yml b/.github/workflows/windows_ci_msvc.yml index e0c824f65..cbc4aa6a0 100644 --- a/.github/workflows/windows_ci_msvc.yml +++ b/.github/workflows/windows_ci_msvc.yml @@ -38,7 +38,7 @@ jobs: run: | echo %VFLAGS% echo $VFLAGS - .\make.bat -msvc + .\makev.bat -msvc .\v.exe symlink - name: Build V with WX run: v -cflags /WX self diff --git a/.github/workflows/windows_ci_tcc.yml b/.github/workflows/windows_ci_tcc.yml index 321c61d5b..d839cfedd 100644 --- a/.github/workflows/windows_ci_tcc.yml +++ b/.github/workflows/windows_ci_tcc.yml @@ -34,9 +34,9 @@ jobs: VTEST_SHOW_LONGEST_BY_TOTALTIME: 3 steps: - uses: actions/checkout@v6 - - name: Build with make.bat -tcc + - name: Build with makev.bat -tcc run: | - .\make.bat -tcc + .\makev.bat -tcc .\v.exe symlink - name: All code is formatted run: v -silent test-cleancode diff --git a/AGENTS.md b/AGENTS.md index a3d9f49af..ef5dcb045 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -249,11 +249,11 @@ See Build & Rebuild for rebuild triggers and flags. ## Prerequisites * Toolchain: `make`, `git`, and a C compiler (`clang` or `gcc`). -* Windows: use `v_make.bat` for the initial build. +* Windows: use `makev.bat` for the initial build. ## Build & Rebuild * Initial build (only if `./v` is missing): `make` - (Windows: `v_make.bat`). + (Windows: `makev.bat`). * Build `./vnew` (debug-friendly, recommended for agent workflows): `./v -g -keepc -o ./vnew cmd/v` * Never run `./v self` directly; only build `./vnew` with the commands diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 40460dc42..37101d2cb 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -57,7 +57,7 @@ Be careful, if you introduce a breaking change and rebuild V, you will no longer be able to use V to build itself. So it's a good idea to make a backup copy of a working compiler executable. -But don't worry, you can always simply run `make` (or `v_make.bat`), it will +But don't worry, you can always simply run `make` (or `makev.bat`), it will download the C version of the compiler and rebuild it from scratch. The architecture of the compiler is very simple and has three distinct steps: diff --git a/GNUmakefile b/GNUmakefile index 7c3affdaa..c873f0dfb 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -363,7 +363,7 @@ selfcompile: selfcompile-static: $(VEXE)$(EXE_EXT) -cg -cflags '--static' -o v-static cmd/v -### NB: Please keep this Makefile and v_make.bat simple. +### NB: Please keep this Makefile and makev.bat simple. install: @echo 'Please use `sudo ./v symlink` instead, or manually add the current directory to your PATH.' diff --git a/README.md b/README.md index 229081ce9..2ff713572 100644 --- a/README.md +++ b/README.md @@ -75,7 +75,7 @@ language, very similar to the way it is right now. Usually, installing V is quite simple if you have an environment that already has a functional `git` installation. -Note: On Windows, run `v_make.bat` instead of `make` in CMD, or `./v_make.bat` in +Note: On Windows, run `makev.bat` instead of `make` in CMD, or `./makev.bat` in PowerShell. Note: On Ubuntu/Debian, you may need to run `sudo apt install git build-essential make` first. @@ -89,7 +89,7 @@ make That should be it, and you should find your V executable at `[path to V repo]/v`. `[path to V repo]` can be anywhere. -(Like the note above says, on Windows, use `v_make.bat`, instead of `make`.) +(Like the note above says, on Windows, use `makev.bat`, instead of `make`.) Now try running `./v run examples/hello_world.v` (or `v run examples/hello_world.v` in cmd shell). diff --git a/cmd/tools/vsymlink/vsymlink_windows.c.v b/cmd/tools/vsymlink/vsymlink_windows.c.v index 2d6aefdf9..6ad1235b8 100644 --- a/cmd/tools/vsymlink/vsymlink_windows.c.v +++ b/cmd/tools/vsymlink/vsymlink_windows.c.v @@ -7,7 +7,7 @@ $if tinyc { fn setup_symlink(custom_link_dir string) { // Create a symlink in a local folder (by default .\.bin\v.exe). - // Puts `v` in %PATH% without polluting it with anything else (like v_make.bat). + // Puts `v` in %PATH% without polluting it with anything else (like makev.bat). // This will make `v` available on cmd.exe, PowerShell, and MinGW(MSYS)/WSL/Cygwin vsymlinkdir := normalized_link_dir(custom_link_dir) mut vsymlink := symlink_path(vsymlinkdir) diff --git a/cmd/tools/vup.v b/cmd/tools/vup.v index f2b172eae..a9d4807e9 100644 --- a/cmd/tools/vup.v +++ b/cmd/tools/vup.v @@ -14,7 +14,7 @@ struct App { vexe string vroot string - skip_v_self bool // do not run `v self`, effectively enforcing the running of `make` or `v_make.bat` + skip_v_self bool // do not run `v self`, effectively enforcing the running of `make` or `makev.bat` skip_current bool // skip the current hash check, enabling easier testing on the same commit, without using docker etc } @@ -247,7 +247,7 @@ fn (app App) install_git() { fn get_make_cmd_name() string { if os.user_os() == 'windows' { - return 'v_make.bat' + return 'makev.bat' } cmd := 'make' make_sure_cmd_is_available(cmd) diff --git a/doc/docs.md b/doc/docs.md index 1676b395a..b5cd7fe56 100644 --- a/doc/docs.md +++ b/doc/docs.md @@ -41,7 +41,7 @@ cd v make ``` -Note: If you are on windows, outside of WSL, run `make.bat` instead of `make`, in a CMD shell. +Note: If you are on windows, outside of WSL, run `makev.bat` instead of `make`, in a CMD shell. Note: On Ubuntu/Debian, you may need to run `sudo apt install git build-essential make` first. For more details, see the diff --git a/doc/packaging_v_for_distributions.md b/doc/packaging_v_for_distributions.md index 8d3e791af..636dd84cd 100644 --- a/doc/packaging_v_for_distributions.md +++ b/doc/packaging_v_for_distributions.md @@ -51,7 +51,7 @@ version of V, and then advises the user to install V from source if he wants to 5) The V source repo contains sizable folders like `.git/` and `thirdparty/tcc/.git/` which will not be needed by users of packages (they are not useful if `v up` is disabled, -as recommended previously). Some other files, such as `Makefile`, `make.bat`, and `GNUmakefile` +as recommended previously). Some other files, such as `Makefile`, `makev.bat`, and `GNUmakefile` will not be used either, so they can also be safely removed. Depending on how stripped you want your package, you can remove the examples/ folder as well. diff --git a/v_make.bat b/makev.bat similarity index 95% rename from v_make.bat rename to makev.bat index bc85e25d0..fa17b498b 100644 --- a/v_make.bat +++ b/makev.bat @@ -299,7 +299,7 @@ goto :eof :usage echo Usage: -echo v_make.bat [target] [compiler] [options] +echo makev.bat [target] [compiler] [options] echo. echo Compiler: echo -msvc ^| -gcc ^| -tcc ^| -tcc32 ^| -clang Set C compiler @@ -313,11 +313,11 @@ echo help Display help for the given target echo rebuild Fully clean/reset repository and rebuild V echo. echo Examples: -echo v_make.bat -msvc -echo v_make.bat -gcc --local -echo v_make.bat build -tcc --local -echo v_make.bat -tcc32 -echo v_make.bat help clean +echo makev.bat -msvc +echo makev.bat -gcc --local +echo makev.bat build -tcc --local +echo makev.bat -tcc32 +echo makev.bat help clean echo. echo Use "make help " for more information about a target, for instance: "make help clean" echo. @@ -326,7 +326,7 @@ exit /b 0 :help_help echo Usage: -echo v_make.bat help [target] +echo makev.bat help [target] echo. echo Target: echo build ^| clean ^| cleanall ^| help Query given target @@ -334,19 +334,19 @@ exit /b 0 :help_clean echo Usage: -echo v_make.bat clean +echo makev.bat clean echo. exit /b 0 :help_cleanall echo Usage: -echo v_make.bat cleanall +echo makev.bat cleanall echo. exit /b 0 :help_build echo Usage: -echo v_make.bat build [compiler] [options] +echo makev.bat build [compiler] [options] echo. echo Compiler: echo -msvc ^| -gcc ^| -tcc ^| -tcc32 ^| -clang Set C compiler @@ -358,7 +358,7 @@ exit /b 0 :help_rebuild echo Usage: -echo v_make.bat rebuild [compiler] [options] +echo makev.bat rebuild [compiler] [options] echo. echo Compiler: echo -msvc ^| -gcc ^| -tcc ^| -tcc32 ^| -clang Set C compiler @@ -423,7 +423,7 @@ endlocal exit /b 0 :move_updated_to_v -@REM del "%V_EXE%" &:: breaks if `v_make.bat` is run from `v up` b/c of held file handle on `%V_EXE%` +@REM del "%V_EXE%" &:: breaks if `makev.bat` is run from `v up` b/c of held file handle on `%V_EXE%` if exist "%V_EXE%" move "%V_EXE%" "%V_OLD%" >nul REM sleep for at most 100ms ping 192.0.2.1 -n 1 -w 100 >nul diff --git a/vlib/os/glob_test.v b/vlib/os/glob_test.v index 1f2dd9b25..4db293baf 100644 --- a/vlib/os/glob_test.v +++ b/vlib/os/glob_test.v @@ -42,7 +42,7 @@ fn test_glob_can_find_files_in_current_folder() { os.chdir(@VMODROOT)! matches := os.glob('*')! assert '.gitignore' in matches - assert 'make.bat' in matches + assert 'makev.bat' in matches assert 'Makefile' in matches assert 'Dockerfile' in matches assert 'README.md' in matches @@ -64,7 +64,7 @@ fn test_glob_star() { os.chdir(@VMODROOT)! matches := os.glob('*ake*')! assert 'Makefile' in matches - assert 'make.bat' in matches + assert 'makev.bat' in matches } fn test_glob_not_found() { diff --git a/vlib/v/parser/containers.v b/vlib/v/parser/containers.v index b9e931ecb..c50933f2c 100644 --- a/vlib/v/parser/containers.v +++ b/vlib/v/parser/containers.v @@ -176,7 +176,10 @@ fn (mut p Parser) array_init(is_option bool, alias_array_type ast.Type) ast.Arra || is_elem_type_expr) && p.tok.line_nr == line_nr { elem_type_pos = p.tok.pos() if is_elem_type_expr { + old_inside_array_init_type_expr := p.inside_array_init_type_expr + p.inside_array_init_type_expr = true elem_type_expr = p.expr(0) + p.inside_array_init_type_expr = old_inside_array_init_type_expr has_type = true } else { elem_type = p.parse_type() diff --git a/vlib/v/parser/expr.v b/vlib/v/parser/expr.v index 85214bce8..4df88d2b4 100644 --- a/vlib/v/parser/expr.v +++ b/vlib/v/parser/expr.v @@ -540,7 +540,7 @@ fn (mut p Parser) parse_typeof_expr(start_pos token.Pos) ast.Expr { p.check(.lpar) expr := p.expr(0) p.check(.rpar) - if p.tok.kind != .dot && p.tok.line_nr == p.prev_tok.line_nr { + if p.tok.kind != .dot && p.tok.line_nr == p.prev_tok.line_nr && !p.inside_array_init_type_expr { if !p.inside_unsafe { p.warn_with_pos('use e.g. `typeof(expr).name` or `sum_type_instance.type_name()` instead', start_pos) @@ -699,7 +699,7 @@ fn (mut p Parser) expr_with_left(left ast.Expr, precedence int, is_stmt_ident bo p.is_stmt_ident = is_stmt_ident continue } - if p.tok.kind == .lcbr && p.tok.is_next_to(p.prev_tok) + if !p.inside_array_init_type_expr && p.tok.kind == .lcbr && p.tok.is_next_to(p.prev_tok) && p.can_use_expr_as_struct_init_type(node) { node = p.struct_init_with_type_expr(node, .normal) p.is_stmt_ident = is_stmt_ident diff --git a/vlib/v/parser/parser.v b/vlib/v/parser/parser.v index 88294825f..dd922677d 100644 --- a/vlib/v/parser/parser.v +++ b/vlib/v/parser/parser.v @@ -50,6 +50,7 @@ mut: inside_unsafe_fn bool inside_str_interp bool inside_array_lit bool + inside_array_init_type_expr bool // parsing `[]typeof(expr){}` element type expression inside_in_array bool inside_infix bool inside_assign_rhs bool // rhs assignment diff --git a/vlib/v/tests/builtin_arrays/array_init_test.v b/vlib/v/tests/builtin_arrays/array_init_test.v index 5fe1c7816..2fca54b9a 100644 --- a/vlib/v/tests/builtin_arrays/array_init_test.v +++ b/vlib/v/tests/builtin_arrays/array_init_test.v @@ -288,9 +288,9 @@ fn empty_array_from_generic_typ[T]() []T { return []T.typ{} } -fn test_array_init_from_typeof_idx() { +fn test_array_init_from_typeof() { fixed := [1, 2, 3]! - dyn := []typeof(fixed[0]).idx{}{} + dyn := []typeof(fixed[0]){} assert typeof(dyn).name == '[]int' assert dyn.len == 0 } diff --git a/vlib/v/util/util.v b/vlib/v/util/util.v index 7e6cc479c..b439a606d 100644 --- a/vlib/v/util/util.v +++ b/vlib/v/util/util.v @@ -246,8 +246,8 @@ pub fn launch_tool(is_verbose bool, tool_name string, args []string) { // `vup.exe` has logic to workaround that, and duplicating it here, is hard to debug/diagnose. eprintln('Failed compilation of the `vup` tool, using the new V source code.') eprintln('The new source code, is likely to be unsupported, by your existing older V executable.') - eprintln('Try running `make` or `make.bat` manually.') - eprintln('If that fails, clone V from source in a new folder, and run `make` or `make.bat` manually again there.') + eprintln('Try running `make` or `makev.bat` manually.') + eprintln('If that fails, clone V from source in a new folder, and run `make` or `makev.bat` manually again there.') l.release() exit(1) } -- 2.39.5