From e35f8e9e23be2d4cdf2b97aa66ce0b6e6559f652 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Thu, 20 Feb 2020 17:05:16 +0100 Subject: [PATCH] checker: return errors --- vlib/v/checker/checker.v | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/vlib/v/checker/checker.v b/vlib/v/checker/checker.v index 6a5ddbd31c..5554c96c02 100644 --- a/vlib/v/checker/checker.v +++ b/vlib/v/checker/checker.v @@ -20,6 +20,7 @@ pub struct Checker { mut: file ast.File nr_errors int + errors []string } pub fn new_checker(table &table.Table) Checker { @@ -38,6 +39,14 @@ pub fn (c mut Checker) check(ast_file ast.File) { } } +pub fn (c mut Checker) check2(ast_file ast.File) []string { + c.file = ast_file + for stmt in ast_file.stmts { + c.stmt(stmt) + } + return c.errors +} + pub fn (c mut Checker) check_files(ast_files []ast.File) { for file in ast_files { c.check(file) @@ -630,6 +639,7 @@ pub fn (c mut Checker) error(s string, pos token.Position) { path = path.replace(workdir, '') } final_msg_line := '$path:$pos.line_nr: checker error #$c.nr_errors: $s' + c.errors << final_msg_line eprintln(final_msg_line) /* if colored_output {