From b451a1b7b0a00d975511dba74f4a191dc497735a Mon Sep 17 00:00:00 2001 From: Turiiya <34311583+ttytm@users.noreply.github.com> Date: Sat, 30 Mar 2024 07:08:37 +0100 Subject: [PATCH 1/4] fix: restore `.v` file endings for metadata/stubs reverts changes from 3c3b24a0c42223992780b142e8b0bd6adfd8cd5a that were causing a regression --- src/metadata/metadata.v | 22 +++++----- src/metadata/stubs/{arrays.vv => arrays.v} | 2 - ...compile_time.vv => builtin_compile_time.v} | 0 src/metadata/stubs/{c_decl.vv => c_decl.v} | 0 .../stubs/{channels.vv => channels.v} | 0 .../stubs/{compile_time.vv => compile_time.v} | 0 ..._constants.vv => compile_time_constants.v} | 0 ...eflection.vv => compile_time_reflection.v} | 0 src/metadata/stubs/{errors.vv => errors.v} | 0 src/metadata/stubs/implicit.v | 15 +------ .../stubs/{primitives.vv => primitives.v} | 0 src/metadata/stubs/{threads.vv => threads.v} | 0 src/metadata/stubs/{vweb.vv => vweb.v} | 0 src/tests/documentation.v | 2 +- .../documentation/{rendered.vv => rendered.v} | 0 .../{rendered.vv.md => rendered.v.md} | 0 src/tests/types.v | 40 +++++++++---------- tree_sitter_v/test/corpus/compile_time.txt | 2 +- 18 files changed, 34 insertions(+), 49 deletions(-) rename src/metadata/stubs/{arrays.vv => arrays.v} (99%) rename src/metadata/stubs/{builtin_compile_time.vv => builtin_compile_time.v} (100%) rename src/metadata/stubs/{c_decl.vv => c_decl.v} (100%) rename src/metadata/stubs/{channels.vv => channels.v} (100%) rename src/metadata/stubs/{compile_time.vv => compile_time.v} (100%) rename src/metadata/stubs/{compile_time_constants.vv => compile_time_constants.v} (100%) rename src/metadata/stubs/{compile_time_reflection.vv => compile_time_reflection.v} (100%) rename src/metadata/stubs/{errors.vv => errors.v} (100%) rename src/metadata/stubs/{primitives.vv => primitives.v} (100%) rename src/metadata/stubs/{threads.vv => threads.v} (100%) rename src/metadata/stubs/{vweb.vv => vweb.v} (100%) rename src/tests/testdata/documentation/{rendered.vv => rendered.v} (100%) rename src/tests/testdata/documentation/{rendered.vv.md => rendered.v.md} (100%) diff --git a/src/metadata/metadata.v b/src/metadata/metadata.v index 9da59cde..ffbbfdd4 100644 --- a/src/metadata/metadata.v +++ b/src/metadata/metadata.v @@ -27,13 +27,13 @@ pub fn (e &EmbedFS) unpack_to(path string) ! { pub fn embed_fs() EmbedFS { mut files := []embed_file.EmbedFileData{} - files << $embed_file('stubs/arrays.vv', .zlib) - files << $embed_file('stubs/primitives.vv', .zlib) - files << $embed_file('stubs/vweb.vv', .zlib) - files << $embed_file('stubs/compile_time_constants.vv', .zlib) - files << $embed_file('stubs/compile_time_reflection.vv', .zlib) - files << $embed_file('stubs/builtin_compile_time.vv', .zlib) - files << $embed_file('stubs/channels.vv', .zlib) + files << $embed_file('stubs/arrays.v', .zlib) + files << $embed_file('stubs/primitives.v', .zlib) + files << $embed_file('stubs/vweb.v', .zlib) + files << $embed_file('stubs/compile_time_constants.v', .zlib) + files << $embed_file('stubs/compile_time_reflection.v', .zlib) + files << $embed_file('stubs/builtin_compile_time.v', .zlib) + files << $embed_file('stubs/channels.v', .zlib) files << $embed_file('stubs/attributes/Deprecated.v', .zlib) files << $embed_file('stubs/attributes/Table.v', .zlib) files << $embed_file('stubs/attributes/Attribute.v', .zlib) @@ -43,10 +43,10 @@ pub fn embed_fs() EmbedFS { files << $embed_file('stubs/attributes/Noreturn.v', .zlib) files << $embed_file('stubs/attributes/Manualfree.v', .zlib) files << $embed_file('stubs/implicit.v', .zlib) - files << $embed_file('stubs/compile_time.vv', .zlib) - files << $embed_file('stubs/c_decl.vv', .zlib) - files << $embed_file('stubs/errors.vv', .zlib) - files << $embed_file('stubs/threads.vv', .zlib) + files << $embed_file('stubs/compile_time.v', .zlib) + files << $embed_file('stubs/c_decl.v', .zlib) + files << $embed_file('stubs/errors.v', .zlib) + files << $embed_file('stubs/threads.v', .zlib) return EmbedFS{ files: files diff --git a/src/metadata/stubs/arrays.vv b/src/metadata/stubs/arrays.v similarity index 99% rename from src/metadata/stubs/arrays.vv rename to src/metadata/stubs/arrays.v index 3537afd7..37e01f06 100644 --- a/src/metadata/stubs/arrays.vv +++ b/src/metadata/stubs/arrays.v @@ -71,7 +71,6 @@ pub: // assert arr[2] == 0 // ``` len int - // cap field represent amount of memory space which has been reserved for elements, // but not initialized or counted as elements // @@ -86,7 +85,6 @@ pub: // arr_with_cap << 100 // no reallocation // ``` cap int - // init field represent default initializer for each element. // // In `init` field, you can use special `index` variable to refer to the current index. diff --git a/src/metadata/stubs/builtin_compile_time.vv b/src/metadata/stubs/builtin_compile_time.v similarity index 100% rename from src/metadata/stubs/builtin_compile_time.vv rename to src/metadata/stubs/builtin_compile_time.v diff --git a/src/metadata/stubs/c_decl.vv b/src/metadata/stubs/c_decl.v similarity index 100% rename from src/metadata/stubs/c_decl.vv rename to src/metadata/stubs/c_decl.v diff --git a/src/metadata/stubs/channels.vv b/src/metadata/stubs/channels.v similarity index 100% rename from src/metadata/stubs/channels.vv rename to src/metadata/stubs/channels.v diff --git a/src/metadata/stubs/compile_time.vv b/src/metadata/stubs/compile_time.v similarity index 100% rename from src/metadata/stubs/compile_time.vv rename to src/metadata/stubs/compile_time.v diff --git a/src/metadata/stubs/compile_time_constants.vv b/src/metadata/stubs/compile_time_constants.v similarity index 100% rename from src/metadata/stubs/compile_time_constants.vv rename to src/metadata/stubs/compile_time_constants.v diff --git a/src/metadata/stubs/compile_time_reflection.vv b/src/metadata/stubs/compile_time_reflection.v similarity index 100% rename from src/metadata/stubs/compile_time_reflection.vv rename to src/metadata/stubs/compile_time_reflection.v diff --git a/src/metadata/stubs/errors.vv b/src/metadata/stubs/errors.v similarity index 100% rename from src/metadata/stubs/errors.vv rename to src/metadata/stubs/errors.v diff --git a/src/metadata/stubs/implicit.v b/src/metadata/stubs/implicit.v index 68ee6c76..fd19e6a9 100644 --- a/src/metadata/stubs/implicit.v +++ b/src/metadata/stubs/implicit.v @@ -6,20 +6,7 @@ module stubs // Any is any type in code. // // It is needed to define all implicit methods of all types. -type Any = []Any - | bool - | f32 - | f64 - | i16 - | i64 - | i8 - | int - | map[string]Any - | string - | u16 - | u32 - | u64 - | u8 +type Any = any // str returns a string representation of the type. // diff --git a/src/metadata/stubs/primitives.vv b/src/metadata/stubs/primitives.v similarity index 100% rename from src/metadata/stubs/primitives.vv rename to src/metadata/stubs/primitives.v diff --git a/src/metadata/stubs/threads.vv b/src/metadata/stubs/threads.v similarity index 100% rename from src/metadata/stubs/threads.vv rename to src/metadata/stubs/threads.v diff --git a/src/metadata/stubs/vweb.vv b/src/metadata/stubs/vweb.v similarity index 100% rename from src/metadata/stubs/vweb.vv rename to src/metadata/stubs/vweb.v diff --git a/src/tests/documentation.v b/src/tests/documentation.v index dba34e8a..9fd917e7 100644 --- a/src/tests/documentation.v +++ b/src/tests/documentation.v @@ -5,7 +5,7 @@ import testing fn documentation() testing.Tester { mut t := testing.with_name('documentation') - t.documentation_test('rendered', 'documentation/rendered.vv') + t.documentation_test('rendered', 'documentation/rendered.v') return t } diff --git a/src/tests/testdata/documentation/rendered.vv b/src/tests/testdata/documentation/rendered.v similarity index 100% rename from src/tests/testdata/documentation/rendered.vv rename to src/tests/testdata/documentation/rendered.v diff --git a/src/tests/testdata/documentation/rendered.vv.md b/src/tests/testdata/documentation/rendered.v.md similarity index 100% rename from src/tests/testdata/documentation/rendered.vv.md rename to src/tests/testdata/documentation/rendered.v.md diff --git a/src/tests/types.v b/src/tests/types.v index 6508a683..04dffeef 100644 --- a/src/tests/types.v +++ b/src/tests/types.v @@ -5,26 +5,26 @@ import testing fn types() testing.Tester { mut t := testing.with_name('types') - t.type_test('literals', 'types/literals.vv') - t.type_test('parameters types', 'types/parameters.vv') - t.type_test('call expressions', 'types/call_expression.vv') - t.type_test('type initializer', 'types/type_initializer.vv') - t.type_test('for loops', 'types/for_loops.vv') - t.type_test('slice and index expression', 'types/slice_and_index_expression.vv') - t.type_test('function literal', 'types/function_literal.vv') - t.type_test('pointers', 'types/pointers.vv') - t.type_test('bool operators', 'types/bool_operators.vv') - t.type_test('unsafe expression', 'types/unsafe_expression.vv') - t.type_test('if expression', 'types/if_expression.vv') - t.type_test('match expression', 'types/match_expression.vv') - t.type_test('map init expression', 'types/map_init_expression.vv') - t.type_test('chan type', 'types/chan_type.vv') - t.type_test('struct fields', 'types/fields.vv') - t.type_test('receiver', 'types/receiver.vv') - t.type_test('json decode', 'types/json_decode.vv') - t.type_test('generics', 'types/generics.vv') - t.type_test('constants', 'types/constants.vv') - t.type_test('for loop', 'types/for_loop.vv') + t.type_test('literals', 'types/literals.v') + t.type_test('parameters types', 'types/parameters.v') + t.type_test('call expressions', 'types/call_expression.v') + t.type_test('type initializer', 'types/type_initializer.v') + t.type_test('for loops', 'types/for_loops.v') + t.type_test('slice and index expression', 'types/slice_and_index_expression.v') + t.type_test('function literal', 'types/function_literal.v') + t.type_test('pointers', 'types/pointers.v') + t.type_test('bool operators', 'types/bool_operators.v') + t.type_test('unsafe expression', 'types/unsafe_expression.v') + t.type_test('if expression', 'types/if_expression.v') + t.type_test('match expression', 'types/match_expression.v') + t.type_test('map init expression', 'types/map_init_expression.v') + t.type_test('chan type', 'types/chan_type.v') + t.type_test('struct fields', 'types/fields.v') + t.type_test('receiver', 'types/receiver.v') + t.type_test('json decode', 'types/json_decode.v') + t.type_test('generics', 'types/generics.v') + t.type_test('constants', 'types/constants.v') + t.type_test('for loop', 'types/for_loop.v') return t } diff --git a/tree_sitter_v/test/corpus/compile_time.txt b/tree_sitter_v/test/corpus/compile_time.txt index f3b19ad7..2e5f1908 100644 --- a/tree_sitter_v/test/corpus/compile_time.txt +++ b/tree_sitter_v/test/corpus/compile_time.txt @@ -1,7 +1,7 @@ ================================================================================ Compile-time call expression ================================================================================ -$embed_file('stubs/arrays.vv', .zlib) +$embed_file('stubs/arrays.v', .zlib) -------------------------------------------------------------------------------- (source_file From e6ef34759d670b354a1a02371a49629d237c7ca5 Mon Sep 17 00:00:00 2001 From: Turiiya <34311583+ttytm@users.noreply.github.com> Date: Sat, 30 Mar 2024 07:15:07 +0100 Subject: [PATCH 2/4] bump stubs version --- src/server/language_server.v | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/server/language_server.v b/src/server/language_server.v index 7f4dceb8..c8559f6a 100644 --- a/src/server/language_server.v +++ b/src/server/language_server.v @@ -47,7 +47,7 @@ pub mut: // stubs_version incremented on each change in stubs // // See also `LanguageServer.setup_stubs()` - stubs_version int = 2 + stubs_version int = 3 // initialization_options is a list of custom initialization options. // Used to pass custom options in tests. initialization_options []string From b43af6cadd15129bc001f4a2ba97f697fd733bd3 Mon Sep 17 00:00:00 2001 From: Turiiya <34311583+ttytm@users.noreply.github.com> Date: Sat, 30 Mar 2024 07:51:53 +0100 Subject: [PATCH 3/4] ci: work around internal vfmt errors --- .github/workflows/analyzer_tests.yml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/analyzer_tests.yml b/.github/workflows/analyzer_tests.yml index d15a24ca..2d0ee1a4 100644 --- a/.github/workflows/analyzer_tests.yml +++ b/.github/workflows/analyzer_tests.yml @@ -66,4 +66,13 @@ jobs: run: v .github/workflows/version_test.vv - name: Verify formatting - run: v fmt -verify -diff . + shell: bash + run: | + set +e + v fmt -c . + exit_code=$? + # Don't fail on internal errors. + if [[ $exit_code -ne 0 && $exit_code -ne 5 ]]; then + v fmt -diff . + exit 1 + fi From 103fc33d66e95a033f976057c67e3c002b9b34a3 Mon Sep 17 00:00:00 2001 From: Turiiya <34311583+ttytm@users.noreply.github.com> Date: Sat, 30 Mar 2024 17:28:26 +0100 Subject: [PATCH 4/4] test stub hover documentation --- src/tests/documentation.v | 1 + src/tests/testdata/documentation/stubs.v | 2 ++ src/tests/testdata/documentation/stubs.v.md | 7 +++++++ 3 files changed, 10 insertions(+) create mode 100644 src/tests/testdata/documentation/stubs.v create mode 100644 src/tests/testdata/documentation/stubs.v.md diff --git a/src/tests/documentation.v b/src/tests/documentation.v index 9fd917e7..a867b712 100644 --- a/src/tests/documentation.v +++ b/src/tests/documentation.v @@ -6,6 +6,7 @@ fn documentation() testing.Tester { mut t := testing.with_name('documentation') t.documentation_test('rendered', 'documentation/rendered.v') + t.documentation_test('stubs', 'documentation/stubs.v') return t } diff --git a/src/tests/testdata/documentation/stubs.v b/src/tests/testdata/documentation/stubs.v new file mode 100644 index 00000000..eedf2f00 --- /dev/null +++ b/src/tests/testdata/documentation/stubs.v @@ -0,0 +1,2 @@ +type Foo = v/*caret*/oidptr + diff --git a/src/tests/testdata/documentation/stubs.v.md b/src/tests/testdata/documentation/stubs.v.md new file mode 100644 index 00000000..ddb5a7f7 --- /dev/null +++ b/src/tests/testdata/documentation/stubs.v.md @@ -0,0 +1,7 @@ +Module: **stubs** +```v +pub type voidptr = voidptr +``` + +voidptr is an untyped pointer. You can pass any other type of pointer value, to a function that accepts a voidptr. +Mostly used for [C interoperability](https://docs.vosca.dev/advanced-concepts/v-and-c.html).