mirror of
https://github.com/vlang/v.git
synced 2025-09-15 15:32:27 +03:00
fmt,vet: handle var in [single_value]
(#5882)
This commit is contained in:
parent
0b0f9c9c06
commit
8a855ccae1
19 changed files with 265 additions and 81 deletions
|
@ -3,7 +3,6 @@
|
|||
module main
|
||||
|
||||
import v.vet
|
||||
import v.ast
|
||||
import v.pref
|
||||
import v.parser
|
||||
import v.util
|
||||
|
@ -13,6 +12,7 @@ import os.cmdline
|
|||
|
||||
struct VetOptions {
|
||||
is_verbose bool
|
||||
errors []string
|
||||
}
|
||||
|
||||
fn (vet_options &VetOptions) vprintln(s string) {
|
||||
|
@ -39,18 +39,20 @@ fn main() {
|
|||
}
|
||||
}
|
||||
}
|
||||
if vet_options.errors.len > 0 {
|
||||
for err in vet_options.errors {
|
||||
eprintln(err)
|
||||
}
|
||||
eprintln('NB: You can run `v fmt -w file.v` to fix these automatically')
|
||||
exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
fn (vet_options &VetOptions) vet_file(path string) {
|
||||
mut prefs := pref.new_preferences()
|
||||
prefs.is_vet = true
|
||||
table := table.new_table()
|
||||
if path.contains('/tests') {
|
||||
return
|
||||
}
|
||||
file_ast := parser.parse_file(path, table, .parse_comments, prefs, &ast.Scope{
|
||||
parent: 0
|
||||
})
|
||||
vet_options.vprintln("vetting file '$path'...")
|
||||
file_ast := parser.parse_vet_file(path, table, prefs, vet_options.errors)
|
||||
vet.vet(file_ast, table, true)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue