Skip to content

Commit

Permalink
fmt checker
Browse files Browse the repository at this point in the history
  • Loading branch information
LouisSchmieder committed Jul 7, 2022
1 parent c0f1fbc commit c2022f8
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 28 deletions.
Binary file added a
Binary file not shown.
26 changes: 26 additions & 0 deletions a.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import sqlite

struct Foo {
id int [primary; sql: serial]
}

fn main() {
db := sqlite.connect(':memory:') ?

mut foo := Foo{}

sql db {
insert foo into Foo
} or {
eprintln(err)
}

res := sql db {
select from Foo
} or {
[]Foo{}
}


eprintln(res)
}
56 changes: 28 additions & 28 deletions vlib/v/checker/checker.v
Original file line number Diff line number Diff line change
Expand Up @@ -272,38 +272,38 @@ pub fn (mut c Checker) check_files(ast_files []&ast.File) {
mut has_main_mod_file := false
mut has_main_fn := false
unsafe {
mut files_from_main_module := []&ast.File{}
for i in 0 .. ast_files.len {
mut file := ast_files[i]
c.timers.start('checker_check $file.path')
c.check(file)
if file.mod.name == 'main' {
files_from_main_module << file
has_main_mod_file = true
if c.file_has_main_fn(file) {
has_main_fn = true
}
}
c.timers.show('checker_check $file.path')
}
if has_main_mod_file && !has_main_fn && files_from_main_module.len > 0 {
if c.pref.is_script && !c.pref.is_test {
// files_from_main_module contain preludes at the start
mut the_main_file := files_from_main_module.last()
the_main_file.stmts << ast.FnDecl{
name: 'main.main'
mod: 'main'
is_main: true
file: the_main_file.path
return_type: ast.void_type
scope: &ast.Scope{
parent: 0
mut files_from_main_module := []&ast.File{}
for i in 0 .. ast_files.len {
mut file := ast_files[i]
c.timers.start('checker_check $file.path')
c.check(file)
if file.mod.name == 'main' {
files_from_main_module << file
has_main_mod_file = true
if c.file_has_main_fn(file) {
has_main_fn = true
}
}
c.timers.show('checker_check $file.path')
}
if has_main_mod_file && !has_main_fn && files_from_main_module.len > 0 {
if c.pref.is_script && !c.pref.is_test {
// files_from_main_module contain preludes at the start
mut the_main_file := files_from_main_module.last()
the_main_file.stmts << ast.FnDecl{
name: 'main.main'
mod: 'main'
is_main: true
file: the_main_file.path
return_type: ast.void_type
scope: &ast.Scope{
parent: 0
}
}
has_main_fn = true
}
has_main_fn = true
}
}
}
c.timers.start('checker_post_process_generic_fns')
last_file := c.file
// post process generic functions. must be done after all files have been
Expand Down

0 comments on commit c2022f8

Please sign in to comment.