Skip to content

Commit d4f28c8

Browse files
authored
checker: minor cleanup in the checker.v (#12945)
1 parent 546c388 commit d4f28c8

File tree

1 file changed

+24
-25
lines changed

1 file changed

+24
-25
lines changed

vlib/v/checker/checker.v

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,13 @@ pub mut:
5454
nr_errors int
5555
nr_warnings int
5656
nr_notices int
57-
should_abort bool // when too many errors/warnings/notices are accumulated, .should_abort becomes true. It is checked in statement/expression loops, so the checker can return early, instead of wasting time.
5857
errors []errors.Error
5958
warnings []errors.Warning
6059
notices []errors.Notice
6160
error_lines []int // to avoid printing multiple errors for the same line
6261
expected_type ast.Type
6362
expected_or_type ast.Type // fn() or { 'this type' } eg. string. expected or block type
63+
mod string // current module name
6464
const_decl string
6565
const_deps []string
6666
const_names []string
@@ -69,50 +69,49 @@ pub mut:
6969
rlocked_names []string // vars that are currently read-locked
7070
in_for_count int // if checker is currently in a for loop
7171
// checked_ident string // to avoid infinite checker loops
72+
should_abort bool // when too many errors/warnings/notices are accumulated, .should_abort becomes true. It is checked in statement/expression loops, so the checker can return early, instead of wasting time.
7273
returns bool
7374
scope_returns bool
74-
mod string // current module name
75-
is_builtin_mod bool // true inside the 'builtin', 'os' or 'strconv' modules; TODO: remove the need for special casing this
76-
is_generated bool // true for `[generated] module xyz` .v files
77-
inside_unsafe bool // true inside `unsafe {}` blocks
78-
inside_const bool // true inside `const ( ... )` blocks
79-
inside_anon_fn bool // true inside `fn() { ... }()`
80-
inside_ref_lit bool // true inside `a := &something`
81-
inside_defer bool // true inside `defer {}` blocks
82-
inside_fn_arg bool // `a`, `b` in `a.f(b)`
83-
inside_ct_attr bool // true inside `[if expr]`
84-
skip_flags bool // should `#flag` and `#include` be skipped
85-
fn_level int // 0 for the top level, 1 for `fn abc() {}`, 2 for a nested fn, etc
75+
is_builtin_mod bool // true inside the 'builtin', 'os' or 'strconv' modules; TODO: remove the need for special casing this
76+
is_generated bool // true for `[generated] module xyz` .v files
77+
inside_unsafe bool // true inside `unsafe {}` blocks
78+
inside_const bool // true inside `const ( ... )` blocks
79+
inside_anon_fn bool // true inside `fn() { ... }()`
80+
inside_ref_lit bool // true inside `a := &something`
81+
inside_defer bool // true inside `defer {}` blocks
82+
inside_fn_arg bool // `a`, `b` in `a.f(b)`
83+
inside_ct_attr bool // true inside `[if expr]`
84+
skip_flags bool // should `#flag` and `#include` be skipped
85+
fn_level int // 0 for the top level, 1 for `fn abc() {}`, 2 for a nested fn, etc
8686
ct_cond_stack []ast.Expr
8787
mut:
8888
stmt_level int // the nesting level inside each stmts list;
8989
// .stmt_level is used to check for `evaluated but not used` ExprStmts like `1 << 1`
9090
// 1 for statements directly at each inner scope level;
9191
// increases for `x := if cond { statement_list1} else {statement_list2}`;
9292
// increases for `x := optfn() or { statement_list3 }`;
93-
is_last_stmt bool
9493
files []ast.File
95-
expr_level int // to avoid infinite recursion segfaults due to compiler bugs
96-
inside_sql bool // to handle sql table fields pseudo variables
94+
expr_level int // to avoid infinite recursion segfaults due to compiler bugs
9795
cur_orm_ts ast.TypeSymbol
9896
error_details []string
9997
vmod_file_content string // needed for @VMOD_FILE, contents of the file, *NOT its path**
100-
vweb_gen_types []ast.Type // vweb route checks
101-
prevent_sum_type_unwrapping_once bool // needed for assign new values to sum type, stopping unwrapping then
10298
loop_label string // set when inside a labelled for loop
99+
vweb_gen_types []ast.Type // vweb route checks
103100
timers &util.Timers = util.get_timers()
104101
comptime_fields_default_type ast.Type
105102
comptime_fields_type map[string]ast.Type
106103
fn_scope &ast.Scope = voidptr(0)
107104
main_fn_decl_node ast.FnDecl
108105
match_exhaustive_cutoff_limit int = 10
109-
// TODO: these are here temporarily and used for deprecations; remove soon
110-
using_new_err_struct bool
111-
inside_selector_expr bool
112-
inside_println_arg bool
113-
inside_decl_rhs bool
114-
inside_if_guard bool // true inside the guard condition of `if x := opt() {}`
115-
need_recheck_generic_fns bool // need recheck generic fns because there are cascaded nested generic fn
106+
is_last_stmt bool
107+
prevent_sum_type_unwrapping_once bool // needed for assign new values to sum type, stopping unwrapping then
108+
using_new_err_struct bool
109+
need_recheck_generic_fns bool // need recheck generic fns because there are cascaded nested generic fn
110+
inside_sql bool // to handle sql table fields pseudo variables
111+
inside_selector_expr bool
112+
inside_println_arg bool
113+
inside_decl_rhs bool
114+
inside_if_guard bool // true inside the guard condition of `if x := opt() {}`
116115
}
117116

118117
pub fn new_checker(table &ast.Table, pref &pref.Preferences) &Checker {

0 commit comments

Comments
 (0)