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 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/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 diff --git a/src/tests/documentation.v b/src/tests/documentation.v index dba34e8a..a867b712 100644 --- a/src/tests/documentation.v +++ b/src/tests/documentation.v @@ -5,7 +5,8 @@ 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') + t.documentation_test('stubs', 'documentation/stubs.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/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). 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