From 1b3385cc34ff783e793d1a26a8ec5be587c80fe0 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Sat, 18 Apr 2026 05:25:30 +0300 Subject: [PATCH] ci: disable old native runs; checker: const/import conflict check --- .github/workflows/linux_ci.yml | 10 --- .github/workflows/native_backend_ci.yml | 78 ------------------- .gitignore | 3 + ci/linux_ci.vsh | 25 ------ vlib/v/checker/checker.v | 11 +++ .../tests/const_import_conflict_err.out | 12 +++ .../tests/const_import_conflict_err.vv | 7 ++ 7 files changed, 33 insertions(+), 113 deletions(-) delete mode 100644 .github/workflows/native_backend_ci.yml create mode 100644 vlib/v/checker/tests/const_import_conflict_err.out create mode 100644 vlib/v/checker/tests/const_import_conflict_err.vv diff --git a/.github/workflows/linux_ci.yml b/.github/workflows/linux_ci.yml index cf1ba5e5b..66cbab294 100644 --- a/.github/workflows/linux_ci.yml +++ b/.github/workflows/linux_ci.yml @@ -80,8 +80,6 @@ jobs: run: v run ci/linux_ci.vsh test_leak_detector_tcc - name: Test leak detector not being active for normal compile run: v run ci/linux_ci.vsh test_leak_detector_not_active_tcc - - name: native cross compilation to macos - run: v run ci/linux_ci.vsh native_cross_compilation_to_macos gcc-linux: runs-on: ubuntu-24.04 @@ -130,10 +128,6 @@ jobs: run: v run ci/linux_ci.vsh v_self_compilation_parallel_cc_gcc - name: Build modules run: v run ci/linux_ci.vsh build_modules_gcc - - name: native machine code generation - run: v run ci/linux_ci.vsh native_machine_code_generation_gcc - - name: native cross compilation to macos - run: v run ci/linux_ci.vsh native_cross_compilation_to_macos - name: compile vdoctor.v with -prod run: v run ci/linux_ci.vsh compile_vdoctor_prod_gcc - name: compile vup.v with -prod @@ -181,7 +175,3 @@ jobs: run: v run ci/linux_ci.vsh build_examples_autofree_clang - name: Build modules run: v run ci/linux_ci.vsh build_modules_clang - - name: native machine code generation - run: v run ci/linux_ci.vsh native_machine_code_generation_clang - - name: native cross compilation to macos - run: v run ci/linux_ci.vsh native_cross_compilation_to_macos diff --git a/.github/workflows/native_backend_ci.yml b/.github/workflows/native_backend_ci.yml deleted file mode 100644 index ca91ba973..000000000 --- a/.github/workflows/native_backend_ci.yml +++ /dev/null @@ -1,78 +0,0 @@ -name: native backend CI - -on: - push: - paths: - - '!**' - - '!**.md' - - 'vlib/v/gen/native/' - - 'cmd/tools/builders/**.v' - - 'vlib/builtin/**.v' - - 'vlib/v/ast/**.v' - - 'vlib/v/scanner/**.v' - - 'vlib/v/parser/**.v' - - 'vlib/v/checker/**.v' - - 'vlib/v/gen/c/**.v' - - 'vlib/v/builder/**.v' - - 'vlib/v/cflag/**.v' - - 'vlib/v/live/**.v' - - 'vlib/v/util/**.v' - - 'vlib/v/markused/**.v' - - 'vlib/v/preludes/**.v' - - 'vlib/v/gen/native/**.v' - - 'vlib/v/gen/native/tests/**.v' - - '.github/workflows/native_backend_ci.yml' - pull_request: - paths: - - '!**' - - '!**.md' - - 'vlib/v/gen/native/' - - 'cmd/tools/builders/**.v' - - 'vlib/builtin/**.v' - - 'vlib/v/ast/**.v' - - 'vlib/v/scanner/**.v' - - 'vlib/v/parser/**.v' - - 'vlib/v/checker/**.v' - - 'vlib/v/gen/c/**.v' - - 'vlib/v/builder/**.v' - - 'vlib/v/cflag/**.v' - - 'vlib/v/live/**.v' - - 'vlib/v/util/**.v' - - 'vlib/v/markused/**.v' - - 'vlib/v/preludes/**.v' - - 'vlib/v/gen/native/**.v' - - 'vlib/v/gen/native/tests/**.v' - - '.github/workflows/native_backend_ci.yml' - -concurrency: - group: native_backend-${{ github.workflow }}-${{ github.ref == 'refs/heads/master' && github.sha || github.ref }} - cancel-in-progress: true - -jobs: - native-backend-ubuntu: - runs-on: ubuntu-24.04 - env: - VJOBS: 1 - steps: - - uses: actions/checkout@v6 - - name: Build V - run: make && ./v symlink - - name: Install linker - run: v retry -- sudo apt -qq install binutils - - name: Rebuild V with -g, for better stacktraces on compiler panics - run: v -g self - - name: Run the native backend tests serially with more details - run: v test vlib/v/gen/native/ - - native-backend-windows: - runs-on: windows-2022 - env: - VJOBS: 1 - steps: - - uses: actions/checkout@v6 - - name: Build V (Windows) - run: ./make.bat && ./v symlink - - name: Rebuild V with -g, for better stacktraces on compiler panics - run: v -g self - - name: Run the native backend tests serially with more details - run: v test vlib/v/gen/native/ diff --git a/.gitignore b/.gitignore index 3a05de018..925ab8389 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,8 @@ # ignore sub-level untracked files and the v binary */**/* +# unignore checker test files +!vlib/v/checker/tests/*.vv +!vlib/v/checker/tests/*.out v v.exe v2 diff --git a/ci/linux_ci.vsh b/ci/linux_ci.vsh index ff2861cdb..51887d38f 100644 --- a/ci/linux_ci.vsh +++ b/ci/linux_ci.vsh @@ -395,28 +395,6 @@ fn build_modules_clang() { exec('v build-module vlib/os/cmdline') } -fn native_machine_code_generation_common() { - exec('cd cmd/tools && v gen1m.v') - exec('cd cmd/tools && ./gen1m > 1m.v') - exec('cd cmd/tools && v -backend native -o 1m 1m.v') - exec('cd cmd/tools && ./1m && ls -larS 1m*') - exec('cd cmd/tools && rm -f ./1m ./1m.v') -} - -fn native_machine_code_generation_gcc() { - native_machine_code_generation_common() -} - -fn native_machine_code_generation_clang() { - native_machine_code_generation_common() -} - -fn native_cross_compilation_to_macos() { - exec('v -os macos -experimental -b native -o hw.macos examples/hello_world.v') - common.file_size_greater_than('hw.macos', 8000) - exec('rm -f hw.macos') -} - fn test_inline_assembly() { exec('v test vlib/v/slow_tests/assembly') } @@ -483,9 +461,6 @@ const all_tasks = { 'build_examples_clang': Task{build_examples_clang, 'Build examples (clang)'} 'build_examples_autofree_clang': Task{build_examples_autofree_clang, 'Build examples with -autofree (clang)'} 'build_modules_clang': Task{build_modules_clang, 'Build modules (clang)'} - 'native_machine_code_generation_clang': Task{native_machine_code_generation_clang, 'native machine code generation (clang)'} - 'native_machine_code_generation_gcc': Task{native_machine_code_generation_gcc, 'native machine code generation (gcc)'} - 'native_cross_compilation_to_macos': Task{native_cross_compilation_to_macos, 'native cross compilation to macos'} 'test_inline_assembly': Task{test_inline_assembly, 'Test inline assembly'} } diff --git a/vlib/v/checker/checker.v b/vlib/v/checker/checker.v index ce29a11f7..30079a5e4 100644 --- a/vlib/v/checker/checker.v +++ b/vlib/v/checker/checker.v @@ -3352,6 +3352,17 @@ fn (mut c Checker) const_decl(mut node ast.ConstDecl) { } c.error('duplicate of a module name `${field.name}`', name_pos) } + for imp in c.file.imports { + imp_alias := if imp.alias.len > 0 { imp.alias } else { imp.mod.all_after_last('.') } + if const_name == imp_alias { + name_pos := token.Pos{ + ...field.pos + len: util.no_cur_mod(field.name, c.mod).len + } + c.error('const `${const_name}` conflicts with imported module `${imp.mod}`', + name_pos) + } + } if const_name == '_' { name_pos := token.Pos{ ...field.pos diff --git a/vlib/v/checker/tests/const_import_conflict_err.out b/vlib/v/checker/tests/const_import_conflict_err.out new file mode 100644 index 000000000..d1fa12e14 --- /dev/null +++ b/vlib/v/checker/tests/const_import_conflict_err.out @@ -0,0 +1,12 @@ +vlib/v/checker/tests/const_import_conflict_err.vv:1:8: warning: module 'strings' is imported but never used. Use `import strings as _`, to silence this warning, or just remove the unused import line + 1 | import strings + | ~~~~~~~ + 2 | + 3 | const strings = ['hello', 'world'] +vlib/v/checker/tests/const_import_conflict_err.vv:3:7: error: const `strings` conflicts with imported module `strings` + 1 | import strings + 2 | + 3 | const strings = ['hello', 'world'] + | ~~~~~~~ + 4 | + 5 | fn main() { diff --git a/vlib/v/checker/tests/const_import_conflict_err.vv b/vlib/v/checker/tests/const_import_conflict_err.vv new file mode 100644 index 000000000..f6eb51a31 --- /dev/null +++ b/vlib/v/checker/tests/const_import_conflict_err.vv @@ -0,0 +1,7 @@ +import strings + +const strings = ['hello', 'world'] + +fn main() { + println(strings) +} -- 2.39.5