From e0441fb5342f8c613daae9c1da2269c32fa078aa Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Wed, 11 Mar 2026 12:45:22 +0300 Subject: [PATCH] v.util: compilation error if theres "-" in path to executed file (fixes #17764) --- vlib/v/tests/hyphenated_module_path_test.v | 38 ++++++++++++++++++++++ vlib/v/util/util.v | 2 +- 2 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 vlib/v/tests/hyphenated_module_path_test.v diff --git a/vlib/v/tests/hyphenated_module_path_test.v b/vlib/v/tests/hyphenated_module_path_test.v new file mode 100644 index 000000000..ee7d4f3b8 --- /dev/null +++ b/vlib/v/tests/hyphenated_module_path_test.v @@ -0,0 +1,38 @@ +import os +import rand + +const vexe = @VEXE + +fn test_module_in_hyphenated_parent_path_compiles() { + test_root := os.join_path(os.vtmp_dir(), 'hyphenated_module_path_${rand.ulid()}') + module_dir := os.join_path(test_root, 'some-dir', 'somemodule') + os.mkdir_all(module_dir)! + defer { + os.rmdir_all(test_root) or {} + } + os.write_file(os.join_path(module_dir, 'somemodule.v'), 'module somemodule + +pub fn value() int { + return 3 +} +')! + os.write_file(os.join_path(module_dir, 'some_test.v'), 'module somemodule + +fn test_value() { + assert value() == 3 +} +')! + old_wd := os.getwd() + defer { + os.chdir(old_wd) or {} + } + os.chdir(test_root)! + module_path := os.join_path('some-dir', 'somemodule') + cmd := '${os.quoted_path(vexe)} test ${os.quoted_path(module_path)}' + res := os.execute(cmd) + if res.exit_code != 0 { + eprintln('> failing test cmd: ${cmd}') + eprintln('> output:\n${res.output}') + } + assert res.exit_code == 0 +} diff --git a/vlib/v/util/util.v b/vlib/v/util/util.v index 4a3f4d390..5c1f1a0c8 100644 --- a/vlib/v/util/util.v +++ b/vlib/v/util/util.v @@ -474,7 +474,7 @@ pub fn strip_main_name(name string) string { @[inline] pub fn no_dots(s string) string { - return s.replace('.', '__') + return s.replace_each(['.', '__', '-', '_']) } const map_prefix = 'map[string]' -- 2.39.5