mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
ci: run v vet vlib/v/parser
This commit is contained in:
parent
40a393926d
commit
da99868a28
3
.github/workflows/ci.yml
vendored
3
.github/workflows/ci.yml
vendored
@ -42,6 +42,9 @@ jobs:
|
||||
run: ./v test-fixed
|
||||
- name: Test building v tools
|
||||
run: ./v build-tools
|
||||
- name: v vet
|
||||
run: |
|
||||
v vet vlib/v/parser
|
||||
# - name: Test v binaries
|
||||
# run: ./v -silent build-vbinaries
|
||||
|
||||
|
7
vlib/v/fmt/tests/comments_keep.vv
Normal file
7
vlib/v/fmt/tests/comments_keep.vv
Normal file
@ -0,0 +1,7 @@
|
||||
struct User {
|
||||
name string // name
|
||||
// last comment
|
||||
// last comment2
|
||||
}
|
||||
|
||||
|
@ -220,7 +220,8 @@ fn (mut p Parser) fn_decl() ast.FnDecl {
|
||||
mut end_pos := p.prev_tok.position()
|
||||
// Return type
|
||||
mut return_type := table.void_type
|
||||
if p.tok.kind.is_start_of_type() || (p.tok.kind == .key_fn && p.tok.line_nr == p.prev_tok.line_nr) {
|
||||
if p.tok.kind.is_start_of_type() || (p.tok.kind == .key_fn &&
|
||||
p.tok.line_nr == p.prev_tok.line_nr) {
|
||||
end_pos = p.tok.position()
|
||||
return_type = p.parse_type()
|
||||
}
|
||||
@ -273,9 +274,12 @@ fn (mut p Parser) fn_decl() ast.FnDecl {
|
||||
if p.tok.kind == .lcbr {
|
||||
stmts = p.parse_block_no_scope(true)
|
||||
// Add return if `fn(...) ? {...}` have no return at end
|
||||
if return_type != table.void_type && p.table.get_type_symbol(return_type).kind == .void &&
|
||||
return_type.has_flag(.optional) && (stmts.len == 0 || stmts[stmts.len-1] !is ast.Return) {
|
||||
stmts << ast.Return{ pos: p.tok.position() }
|
||||
if return_type != table.void_type &&
|
||||
p.table.get_type_symbol(return_type).kind == .void && return_type.has_flag(.optional) &&
|
||||
(stmts.len == 0 || stmts[stmts.len - 1] !is ast.Return) {
|
||||
stmts << ast.Return{
|
||||
pos: p.tok.position()
|
||||
}
|
||||
}
|
||||
}
|
||||
p.close_scope()
|
||||
@ -376,7 +380,8 @@ fn (mut p Parser) fn_args() ([]table.Arg, bool, bool) {
|
||||
mut is_variadic := false
|
||||
// `int, int, string` (no names, just types)
|
||||
argname := if p.tok.kind == .name && p.tok.lit.len > 0 && p.tok.lit[0].is_capital() { p.prepend_mod(p.tok.lit) } else { p.tok.lit }
|
||||
types_only := p.tok.kind in [.amp, .ellipsis, .key_fn] || (p.peek_tok.kind == .comma && p.table.known_type(argname)) ||
|
||||
types_only := p.tok.kind in [.amp, .ellipsis, .key_fn] ||
|
||||
(p.peek_tok.kind == .comma && p.table.known_type(argname)) ||
|
||||
p.peek_tok.kind == .rpar
|
||||
// TODO copy pasta, merge 2 branches
|
||||
if types_only {
|
||||
|
Loading…
Reference in New Issue
Block a user