diff --git a/vlib/os/os_nix.v b/vlib/os/os_nix.v index 41b2f4e5ad..6b4ae7aab3 100644 --- a/vlib/os/os_nix.v +++ b/vlib/os/os_nix.v @@ -98,14 +98,14 @@ pub fn create(path string) ?File { $if linux { //$if linux_or_macos { mut fd := 0 - println('creat SYS') + //println('creat SYS') $if macos { fd = C.syscall(sys_open_nocancel, path.str, 0x601, 0x1b6) } $else { fd = C.syscall(sys_creat, path.str, 511) } - println('fd=$fd') + //println('fd=$fd') if fd == -1 { return error('failed to create file "$path"') } diff --git a/vlib/v/gen/cgen_test.v b/vlib/v/gen/cgen_test.v index c93eabac82..9c7d0a72a1 100644 --- a/vlib/v/gen/cgen_test.v +++ b/vlib/v/gen/cgen_test.v @@ -17,14 +17,12 @@ fn test_c_files() { vexe := os.getenv('VEXE') vroot := filepath.dir(vexe) for i in 1 .. nr_tests + 1 { - text := os.read_file('$vroot/vlib/v/gen/tests/${i}.vv') or { - panic(err) - } + path := '$vroot/vlib/v/gen/tests/${i}.vv' ctext := os.read_file('$vroot/vlib/v/gen/tests/${i}.c') or { panic(err) } table := &table.Table{} - program := parser.parse_file(text, table) + program := parser.parse_file(path, table) res := gen.cgen([program]) if compare_texts(res, ctext) { eprintln('${i}... ' + term.green('OK')) diff --git a/vlib/v/gen/tests/2.vv b/vlib/v/gen/tests/2.vv index 082f6db5cd..389b25dad9 100644 --- a/vlib/v/gen/tests/2.vv +++ b/vlib/v/gen/tests/2.vv @@ -4,7 +4,9 @@ fn function1() int { return 0 } -fn foo(a int) {} +fn foo(a int) { + end() +} struct User { name string @@ -57,5 +59,9 @@ fn init_array() { } +fn end() { + +} + fn main() { } diff --git a/vlib/v/parser/parser.v b/vlib/v/parser/parser.v index 7fe87f05d5..71ae29ab33 100644 --- a/vlib/v/parser/parser.v +++ b/vlib/v/parser/parser.v @@ -62,11 +62,15 @@ pub fn (p mut Parser) get_type() types.Type { } } -pub fn parse_file(text string, table &table.Table) ast.File { +pub fn parse_file(path string, table &table.Table) ast.File { + text := os.read_file(path) or { + panic(err) + } mut stmts := []ast.Stmt mut p := Parser{ scanner: scanner.new_scanner(text) table: table + file_name: path } p.read_first_token() for {