From 80536d68d80dee2617feadebd55c073fe349ac3e Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Fri, 24 Apr 2026 01:35:02 +0300 Subject: [PATCH] v.tests: fix Compiler thinks there is an @ at line 3 of a file every time. (fixes #26873) --- .gitignore | 2 ++ vlib/v/tests/project_issue_26873/ct_var.v | 3 ++ .../escaped_keyword_attr.v | 31 +++++++++++++++++++ .../project_issue_26873/header_comment.v | 9 ++++++ vlib/v/tests/project_issue_26873/import_os.v | 7 +++++ vlib/v/tests/project_issue_26873/main.v | 11 +++++++ .../project_issue_26873/split_sum_type.v | 22 +++++++++++++ vlib/v/tests/project_issue_26873/v.mod | 3 ++ vlib/v/tests/project_issue_26873_check_test.v | 9 ++++++ 9 files changed, 97 insertions(+) create mode 100644 vlib/v/tests/project_issue_26873/ct_var.v create mode 100644 vlib/v/tests/project_issue_26873/escaped_keyword_attr.v create mode 100644 vlib/v/tests/project_issue_26873/header_comment.v create mode 100644 vlib/v/tests/project_issue_26873/import_os.v create mode 100644 vlib/v/tests/project_issue_26873/main.v create mode 100644 vlib/v/tests/project_issue_26873/split_sum_type.v create mode 100644 vlib/v/tests/project_issue_26873/v.mod create mode 100644 vlib/v/tests/project_issue_26873_check_test.v diff --git a/.gitignore b/.gitignore index a751643b8..9a55f1c49 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,8 @@ !vlib/v/gen/c/testdata/nested_unary_minus_regression.out !vlib/v/tests/interfaces/interface_pointer_method_value_issue_22237_test.v !vlib/v/tests/net_http_request_proxy_interpolation_test.v +!vlib/v/tests/project_issue_26873/** +!vlib/v/tests/project_issue_26873_check_test.v !vlib/v/checker/tests/modules/c_type_cast_imported_from_module/** !vlib/v/checker/tests/modules/c_type_cast_imported_from_module.out !vlib/veb/tests/catchall_route_order_regression_test.v diff --git a/vlib/v/tests/project_issue_26873/ct_var.v b/vlib/v/tests/project_issue_26873/ct_var.v new file mode 100644 index 000000000..b061fff27 --- /dev/null +++ b/vlib/v/tests/project_issue_26873/ct_var.v @@ -0,0 +1,3 @@ +module main + +const project_root = @VMODROOT diff --git a/vlib/v/tests/project_issue_26873/escaped_keyword_attr.v b/vlib/v/tests/project_issue_26873/escaped_keyword_attr.v new file mode 100644 index 000000000..c5037499e --- /dev/null +++ b/vlib/v/tests/project_issue_26873/escaped_keyword_attr.v @@ -0,0 +1,31 @@ +module main + +pub enum ContentType { + none + block + inline +} + +pub struct Content { +pub: + @type ContentType + data string +} + +@[params] +struct Options { + path string @[required] +} + +fn new_content(data string) Content { + return Content{ + @type: .block + data: data + } +} + +fn make_options(opts Options) Options { + return Options{ + ...opts + } +} diff --git a/vlib/v/tests/project_issue_26873/header_comment.v b/vlib/v/tests/project_issue_26873/header_comment.v new file mode 100644 index 000000000..a41a3e158 --- /dev/null +++ b/vlib/v/tests/project_issue_26873/header_comment.v @@ -0,0 +1,9 @@ +// Copyright 2026 The V contributors. +// +// Licensed under the Apache License, Version 2.0. + +module main + +fn header_comment_ok() int { + return 1 +} diff --git a/vlib/v/tests/project_issue_26873/import_os.v b/vlib/v/tests/project_issue_26873/import_os.v new file mode 100644 index 000000000..f74396714 --- /dev/null +++ b/vlib/v/tests/project_issue_26873/import_os.v @@ -0,0 +1,7 @@ +module main + +import os + +fn temp_root() string { + return os.temp_dir() +} diff --git a/vlib/v/tests/project_issue_26873/main.v b/vlib/v/tests/project_issue_26873/main.v new file mode 100644 index 000000000..752856b36 --- /dev/null +++ b/vlib/v/tests/project_issue_26873/main.v @@ -0,0 +1,11 @@ +module main + +fn main() { + content := new_content('data') + assert content.@type == .block + assert temp_root().len > 0 + assert project_root.len > 0 + assert sum_type_count() == 2 + assert make_options(path: project_root).path == project_root + assert header_comment_ok() == 1 +} diff --git a/vlib/v/tests/project_issue_26873/split_sum_type.v b/vlib/v/tests/project_issue_26873/split_sum_type.v new file mode 100644 index 000000000..7b5ff8916 --- /dev/null +++ b/vlib/v/tests/project_issue_26873/split_sum_type.v @@ -0,0 +1,22 @@ +module main + +pub type SplitNode = EditorLeaf | SplitContainer + +pub struct EditorLeaf { + id int +} + +pub struct SplitContainer { + children []SplitNode +} + +fn sum_type_count() int { + node := SplitContainer{ + children: [SplitNode(EditorLeaf{ + id: 1 + }), SplitNode(EditorLeaf{ + id: 2 + })] + } + return node.children.len +} diff --git a/vlib/v/tests/project_issue_26873/v.mod b/vlib/v/tests/project_issue_26873/v.mod new file mode 100644 index 000000000..13a47102e --- /dev/null +++ b/vlib/v/tests/project_issue_26873/v.mod @@ -0,0 +1,3 @@ +Module { + name: 'project_issue_26873' +} diff --git a/vlib/v/tests/project_issue_26873_check_test.v b/vlib/v/tests/project_issue_26873_check_test.v new file mode 100644 index 000000000..9ac5a47e5 --- /dev/null +++ b/vlib/v/tests/project_issue_26873_check_test.v @@ -0,0 +1,9 @@ +import os + +const vexe = os.quoted_path(@VEXE) +const issue_26873_project = os.join_path(os.dir(@FILE), 'project_issue_26873') + +fn test_project_with_line_three_top_level_tokens_checks_cleanly() { + res := os.execute('${vexe} -check ${os.quoted_path(issue_26873_project)}') + assert res.exit_code == 0, res.output +} -- 2.39.5