Module v.checker stdlib

Dependencies from vmod:
Imported by:
Show selected OS-specific symbols.
Show selected Backend-specific symbols.

Dependencies defined in v.mod

This section is empty.

Imported by


This section is empty.


#constant array_builtin_methods

array_builtin_methods       = ['filter', 'clone', 'repeat', 'reverse', 'map', 'slice', 'sort',
	'contains', 'index', 'wait', 'any', 'all', 'first', 'last', 'pop', 'delete']

#constant array_builtin_methods_chk

array_builtin_methods_chk   = token.new_keywords_matcher_from_array_trie(array_builtin_methods)

#constant reserved_type_names

reserved_type_names         = ['byte', 'bool', 'char', 'i8', 'i16', 'int', 'i64', 'u8', 'u16',
	'u32', 'u64', 'f32', 'f64', 'map', 'string', 'rune', 'usize', 'isize', 'voidptr']

#constant reserved_type_names_chk

reserved_type_names_chk     = token.new_keywords_matcher_from_array_trie(reserved_type_names)

#constant vroot_is_deprecated_message

vroot_is_deprecated_message = '@VROOT is deprecated, use @VMODROOT or @VEXEROOT instead'

Sum types

This section is empty.


This section is empty.


#struct Checker

pub struct Checker {
	pref &pref.Preferences = unsafe { nil } // Preferences shared from V struct
pub mut:
	table                     &ast.Table = unsafe { nil }
	file                      &ast.File  = unsafe { nil }
	nr_errors                 int
	nr_warnings               int
	nr_notices                int
	errors                    []errors.Error
	warnings                  []errors.Warning
	notices                   []errors.Notice
	error_lines               []int // to avoid printing multiple errors for the same line
	expected_type             ast.Type
	expected_or_type          ast.Type        // fn() or { 'this type' } eg. string. expected or block type
	expected_expr_type        ast.Type        // if/match is_expr: expected_type
	mod                       string          // current module name
	const_var                 &ast.ConstField = unsafe { nil } // the current constant, when checking const declarations
	const_deps                []string
	const_names               []string
	global_names              []string
	locked_names              []string // vars that are currently locked
	rlocked_names             []string // vars that are currently read-locked
	in_for_count              int      // if checker is currently in a for loop
	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.
	returns                   bool
	scope_returns             bool
	is_builtin_mod            bool // true inside the 'builtin', 'os' or 'strconv' modules; TODO: remove the need for special casing this
	is_just_builtin_mod       bool // true only inside 'builtin'
	is_generated              bool // true for `[generated] module xyz` .v files
	inside_unsafe             bool // true inside `unsafe {}` blocks
	inside_const              bool // true inside `const ( ... )` blocks
	inside_anon_fn            bool // true inside `fn() { ... }()`
	inside_ref_lit            bool // true inside `a := &something`
	inside_defer              bool // true inside `defer {}` blocks
	inside_fn_arg             bool // `a`, `b` in `a.f(b)`
	inside_ct_attr            bool // true inside `[if expr]`
	inside_x_is_type          bool // true inside the Type expression of `if x is Type {`
	inside_comptime_for_field bool
	skip_flags                bool      // should `#flag` and `#include` be skipped
	fn_level                  int       // 0 for the top level, 1 for `fn abc() {}`, 2 for a nested fn, etc
	smartcast_mut_pos         token.Pos // match mut foo, if mut foo is Foo
	smartcast_cond_pos        token.Pos // match cond
	ct_cond_stack             []ast.Expr
	stmt_level int // the nesting level inside each stmts list;
	// .stmt_level is used to check for `evaluated but not used` ExprStmts like `1 << 1`
	// 1 for statements directly at each inner scope level;
	// increases for `x := if cond { statement_list1} else {statement_list2}`;
	// increases for `x := optfn() or { statement_list3 }`;
	files                            []ast.File
	expr_level                       int // to avoid infinite recursion segfaults due to compiler bugs
	ensure_generic_type_level        int // to avoid infinite recursion segfaults in ensure_generic_type_specify_type_names
	cur_orm_ts                       ast.TypeSymbol
	cur_anon_fn                      &ast.AnonFn = unsafe { nil }
	error_details                    []string
	vmod_file_content                string     // needed for @VMOD_FILE, contents of the file, *NOT its path**
	loop_label                       string     // set when inside a labelled for loop
	vweb_gen_types                   []ast.Type // vweb route checks
	timers                           &util.Timers = util.get_timers()
	comptime_for_field_var           string
	comptime_fields_default_type     ast.Type
	comptime_fields_type             map[string]ast.Type
	comptime_for_field_value         ast.StructField // value of the field variable
	comptime_enum_field_value        string // current enum value name
	fn_scope                         &ast.Scope = unsafe { nil }
	main_fn_decl_node                ast.FnDecl
	match_exhaustive_cutoff_limit    int = 10
	is_last_stmt                     bool
	prevent_sum_type_unwrapping_once bool // needed for assign new values to sum type, stopping unwrapping then
	using_new_err_struct             bool
	need_recheck_generic_fns         bool // need recheck generic fns because there are cascaded nested generic fn
	inside_sql                       bool // to handle sql table fields pseudo variables
	inside_selector_expr             bool
	inside_println_arg               bool
	inside_decl_rhs                  bool
	inside_if_guard                  bool // true inside the guard condition of `if x := opt() {}`
	inside_assign                    bool
	is_index_assign                  bool
	comptime_call_pos                int // needed for correctly checking use before decl for templates
	goto_labels                      map[string]ast.GotoLabel // to check for unused goto labels
	enum_data_type                   ast.Type

#fn new_checker

fn new_checker(table &v.ast.Table, pref_ &v.pref.Preferences) &Checker

#fn (&Checker) assign_stmt

fn (mut c &Checker) assign_stmt(mut node &v.ast.AssignStmt)

TODO 600 line function

#fn (&Checker) check_types

fn (mut c &Checker) check_types(got v.ast.Type, expected v.ast.Type) bool

TODO: promote(), check_types(), symmetric_check() and check() overlap - should be rearranged

#fn (Checker) check_multiple_ptr_match

fn (c Checker) check_multiple_ptr_match(got v.ast.Type, expected v.ast.Type, param v.ast.Param, arg v.ast.CallArg) bool

#fn (&Checker) check_expected_call_arg

fn (mut c &Checker) check_expected_call_arg(got v.ast.Type, expected_ v.ast.Type, language v.ast.Language, arg v.ast.CallArg) !

#fn (Checker) get_string_names_of

fn (c Checker) get_string_names_of(got v.ast.Type, expected v.ast.Type) (string, string)

#fn (Checker) check_same_module

fn (c Checker) check_same_module(got v.ast.Type, expected v.ast.Type) bool

helper method to check if the type is of the same module.

FIXME(vincenzopalazzo) This is a work around to the issue explained in the

#fn (&Checker) check_basic

fn (mut c &Checker) check_basic(got v.ast.Type, expected v.ast.Type) bool

#fn (&Checker) check_matching_function_symbols

fn (mut c &Checker) check_matching_function_symbols(got_type_sym &v.ast.TypeSymbol, exp_type_sym &v.ast.TypeSymbol) bool

#fn (&Checker) check_shift

fn (mut c &Checker) check_shift(mut node &v.ast.InfixExpr, left_type_ v.ast.Type, right_type_ v.ast.Type) v.ast.Type

#fn (&Checker) promote_keeping_aliases

fn (mut c &Checker) promote_keeping_aliases(left_type v.ast.Type, right_type v.ast.Type, left_kind v.ast.Kind, right_kind v.ast.Kind) v.ast.Type

#fn (&Checker) promote

fn (mut c &Checker) promote(left_type v.ast.Type, right_type v.ast.Type) v.ast.Type

#fn (&Checker) promote_num

fn (c &Checker) promote_num(left_type v.ast.Type, right_type v.ast.Type) v.ast.Type

#fn (&Checker) check_expected

fn (mut c &Checker) check_expected(got v.ast.Type, expected v.ast.Type) !

#fn (&Checker) expected_msg

fn (c &Checker) expected_msg(got v.ast.Type, expected v.ast.Type) string

#fn (&Checker) symmetric_check

fn (mut c &Checker) symmetric_check(left v.ast.Type, right v.ast.Type) bool

#fn (&Checker) infer_struct_generic_types

fn (mut c &Checker) infer_struct_generic_types(typ v.ast.Type, node v.ast.StructInit) []v.ast.Type

#fn (Checker) get_generic_array_element_type

fn (g Checker) get_generic_array_element_type(array v.ast.Array) v.ast.Type

#fn (Checker) get_generic_array_fixed_element_type

fn (g Checker) get_generic_array_fixed_element_type(array v.ast.ArrayFixed) v.ast.Type

#fn (&Checker) infer_fn_generic_types

fn (mut c &Checker) infer_fn_generic_types(func v.ast.Fn, mut node &v.ast.CallExpr)

#fn (&Checker) reset_checker_state_at_start_of_new_file

fn (mut c &Checker) reset_checker_state_at_start_of_new_file()

#fn (&Checker) check

fn (mut c &Checker) check(ast_file_ &v.ast.File)

#fn (&Checker) check_scope_vars

fn (mut c &Checker) check_scope_vars(sc &v.ast.Scope)

#fn (&Checker) check2

fn (mut c &Checker) check2(ast_file &v.ast.File) []v.errors.Error

not used right now

#fn (&Checker) change_current_file

fn (mut c &Checker) change_current_file(file &v.ast.File)

#fn (&Checker) check_files

fn (mut c &Checker) check_files(ast_files []&v.ast.File)

#fn (&Checker) file_has_main_fn

fn (mut c &Checker) file_has_main_fn(file &v.ast.File) bool

do checks specific to files in main module returns true if a main function is in the file

#fn (&Checker) check_valid_snake_case

fn (mut c &Checker) check_valid_snake_case(name string, identifier string, pos v.token.Pos)

#fn (&Checker) check_valid_pascal_case

fn (mut c &Checker) check_valid_pascal_case(name string, identifier string, pos v.token.Pos)

#fn (&Checker) type_decl

fn (mut c &Checker) type_decl(node v.ast.TypeDecl)

#fn (&Checker) alias_type_decl

fn (mut c &Checker) alias_type_decl(node v.ast.AliasTypeDecl)

#fn (&Checker) check_alias_vs_element_type_of_parent

fn (mut c &Checker) check_alias_vs_element_type_of_parent(node v.ast.AliasTypeDecl, element_type_of_parent v.ast.Type, label string)

#fn (&Checker) fn_type_decl

fn (mut c &Checker) fn_type_decl(node v.ast.FnTypeDecl)

#fn (&Checker) sum_type_decl

fn (mut c &Checker) sum_type_decl(node v.ast.SumTypeDecl)

#fn (&Checker) expand_iface_embeds

fn (mut c &Checker) expand_iface_embeds(idecl &v.ast.InterfaceDecl, level int, iface_embeds []v.ast.InterfaceEmbedding) []v.ast.InterfaceEmbedding

#fn (&Checker) fail_if_immutable

fn (mut c &Checker) fail_if_immutable(expr_ v.ast.Expr) (string, v.token.Pos)

returns name and position of variable that needs write lock also sets is_changed to true (TODO update the name to reflect this?)

#fn (&Checker) type_implements

fn (mut c &Checker) type_implements(typ v.ast.Type, interface_type v.ast.Type, pos v.token.Pos) bool

#fn (&Checker) check_expr_opt_call

fn (mut c &Checker) check_expr_opt_call(expr v.ast.Expr, ret_type v.ast.Type) v.ast.Type

return the actual type of the expression, once the option is handled

#fn (&Checker) check_or_expr

fn (mut c &Checker) check_or_expr(node v.ast.OrExpr, ret_type v.ast.Type, expr_return_type v.ast.Type, expr v.ast.Expr)

#fn (&Checker) check_or_last_stmt

fn (mut c &Checker) check_or_last_stmt(stmt v.ast.Stmt, ret_type v.ast.Type, expr_return_type v.ast.Type)

#fn (&Checker) selector_expr

fn (mut c &Checker) selector_expr(mut node &v.ast.SelectorExpr) v.ast.Type

#fn (&Checker) const_decl

fn (mut c &Checker) const_decl(mut node &v.ast.ConstDecl)

#fn (&Checker) enum_decl

fn (mut c &Checker) enum_decl(mut node &v.ast.EnumDecl)

#fn (&Checker) check_loop_label

fn (mut c &Checker) check_loop_label(label string, pos v.token.Pos)

#fn (&Checker) stmt

fn (mut c &Checker) stmt(node_ v.ast.Stmt)

#fn (&Checker) assert_stmt

fn (mut c &Checker) assert_stmt(node v.ast.AssertStmt)

#fn (&Checker) block

fn (mut c &Checker) block(node v.ast.Block)

#fn (&Checker) branch_stmt

fn (mut c &Checker) branch_stmt(node v.ast.BranchStmt)

#fn (&Checker) global_decl

fn (mut c &Checker) global_decl(mut node &v.ast.GlobalDecl)

#fn (&Checker) asm_stmt

fn (mut c &Checker) asm_stmt(mut stmt &v.ast.AsmStmt)

#fn (&Checker) asm_arg

fn (mut c &Checker) asm_arg(arg v.ast.AsmArg, stmt v.ast.AsmStmt, aliases []string)

#fn (&Checker) asm_ios

fn (mut c &Checker) asm_ios(ios []v.ast.AsmIO, mut scope &v.ast.Scope, output bool) []string

#fn (&Checker) hash_stmt

fn (mut c &Checker) hash_stmt(mut node &v.ast.HashStmt)

#fn (&Checker) import_stmt

fn (mut c &Checker) import_stmt(node v.ast.Import)

#fn (&Checker) stmts

fn (mut c &Checker) stmts(stmts []v.ast.Stmt)

stmts should be used for processing normal statement lists (fn bodies, for loop bodies etc).

#fn (&Checker) stmts_ending_with_expression

fn (mut c &Checker) stmts_ending_with_expression(stmts []v.ast.Stmt)

stmts_ending_with_expression, should be used for processing list of statements, that can end with an expression.

Examples for such lists are the bodies of or blocks, if expressions and match expressions:

x := opt() or { stmt1 stmt2 ExprStmt }, x := if cond { stmt1 stmt2 ExprStmt } else { stmt2 stmt3 ExprStmt }, x := match expr { Type1 { stmt1 stmt2 ExprStmt } else { stmt2 stmt3 ExprStmt }.

#fn (&Checker) unwrap_generic

fn (mut c &Checker) unwrap_generic(typ v.ast.Type) v.ast.Type

#fn (&Checker) expr

fn (mut c &Checker) expr(node_ v.ast.Expr) v.ast.Type

TODO node must be mut

#fn (&Checker) cast_expr

fn (mut c &Checker) cast_expr(mut node &v.ast.CastExpr) v.ast.Type

#fn (&Checker) at_expr

fn (mut c &Checker) at_expr(mut node &v.ast.AtExpr) v.ast.Type

#fn (&Checker) ident

fn (mut c &Checker) ident(mut node &v.ast.Ident) v.ast.Type

#fn (&Checker) concat_expr

fn (mut c &Checker) concat_expr(mut node &v.ast.ConcatExpr) v.ast.Type

#fn (&Checker) smartcast

fn (mut c &Checker) smartcast(expr_ v.ast.Expr, cur_type v.ast.Type, to_type_ v.ast.Type, mut scope &v.ast.Scope)

smartcast takes the expression with the current type which should be smartcasted to the target type in the given scope

#fn (&Checker) select_expr

fn (mut c &Checker) select_expr(mut node &v.ast.SelectExpr) v.ast.Type

#fn (&Checker) lock_expr

fn (mut c &Checker) lock_expr(mut node &v.ast.LockExpr) v.ast.Type

#fn (&Checker) unsafe_expr

fn (mut c &Checker) unsafe_expr(mut node &v.ast.UnsafeExpr) v.ast.Type

#fn (&Checker) find_definition

fn (mut c &Checker) find_definition(ident v.ast.Ident) !v.ast.Expr

#fn (&Checker) find_obj_definition

fn (mut c &Checker) find_obj_definition(obj v.ast.ScopeObject) !v.ast.Expr

#fn (&Checker) has_return

fn (c &Checker) has_return(stmts []v.ast.Stmt) ?bool

#fn (&Checker) is_comptime_var

fn (mut c &Checker) is_comptime_var(node v.ast.Expr) bool

#fn (&Checker) mark_as_referenced

fn (mut c &Checker) mark_as_referenced(mut node &v.ast.Expr, as_interface bool)

#fn (&Checker) get_base_name

fn (mut c &Checker) get_base_name(node &v.ast.Expr) string

#fn (&Checker) prefix_expr

fn (mut c &Checker) prefix_expr(mut node &v.ast.PrefixExpr) v.ast.Type

#fn (&Checker) type_error_for_operator

fn (mut c &Checker) type_error_for_operator(op_label string, types_label string, found_type_label string, pos v.token.Pos)

#fn (&Checker) check_index

fn (mut c &Checker) check_index(typ_sym &v.ast.TypeSymbol, index v.ast.Expr, index_type v.ast.Type, pos v.token.Pos, range_index bool, is_gated bool)

#fn (&Checker) index_expr

fn (mut c &Checker) index_expr(mut node &v.ast.IndexExpr) v.ast.Type

#fn (&Checker) enum_val

fn (mut c &Checker) enum_val(mut node &v.ast.EnumVal) v.ast.Type

.green or If a short form is used, expected_type needs to be an enum with this value.

#fn (&Checker) chan_init

fn (mut c &Checker) chan_init(mut node &v.ast.ChanInit) v.ast.Type

#fn (&Checker) offset_of

fn (mut c &Checker) offset_of(node v.ast.OffsetOf) v.ast.Type

#fn (&Checker) check_dup_keys

fn (mut c &Checker) check_dup_keys(node &v.ast.MapInit, i int)

#fn (&Checker) add_error_detail

fn (mut c &Checker) add_error_detail(s string)

call this before calling error or warn

#fn (&Checker) add_error_detail_with_pos

fn (mut c &Checker) add_error_detail_with_pos(msg string, pos v.token.Pos)

#fn (&Checker) add_instruction_for_option_type

fn (mut c &Checker) add_instruction_for_option_type()

#fn (&Checker) add_instruction_for_result_type

fn (mut c &Checker) add_instruction_for_result_type()

#fn (&Checker) warn

fn (mut c &Checker) warn(s string, pos v.token.Pos)

#fn (&Checker) error

fn (mut c &Checker) error(message string, pos v.token.Pos)

#fn (&Checker) check_struct_signature_init_fields

fn (c &Checker) check_struct_signature_init_fields(from v.ast.Struct, to v.ast.Struct, node v.ast.StructInit) bool

#fn (&Checker) check_struct_signature

fn (c &Checker) check_struct_signature(from v.ast.Struct, to v.ast.Struct) bool

check to has all fields of from

#fn (&Checker) note

fn (mut c &Checker) note(message string, pos v.token.Pos)

#fn (&Checker) warn_or_error

fn (mut c &Checker) warn_or_error(message string, pos v.token.Pos, warn bool)

#fn (&Checker) fileis

fn (c &Checker) fileis(s string) bool

for debugging only

#fn (&Checker) fetch_field_name

fn (mut c &Checker) fetch_field_name(field v.ast.StructField) string

#fn (&Checker) trace

fn (mut c &Checker) trace(fbase string, message string)

#fn (&Checker) ensure_generic_type_specify_type_names

fn (mut c &Checker) ensure_generic_type_specify_type_names(typ v.ast.Type, pos v.token.Pos) ?

#fn (&Checker) ensure_type_exists

fn (mut c &Checker) ensure_type_exists(typ v.ast.Type, pos v.token.Pos) ?

#fn (&Checker) fail_if_unreadable

fn (mut c &Checker) fail_if_unreadable(expr v.ast.Expr, typ v.ast.Type, what string)

#fn (&Checker) goto_label

fn (mut c &Checker) goto_label(node v.ast.GotoLabel)

#fn (&Checker) goto_stmt

fn (mut c &Checker) goto_stmt(node v.ast.GotoStmt)

#fn (&Checker) check_unused_labels

fn (mut c &Checker) check_unused_labels()

#fn (&Checker) deprecate

fn (mut c &Checker) deprecate(kind string, name string, attrs []v.ast.Attr, pos v.token.Pos)

#fn (&Checker) deprecate_old_isreftype_and_sizeof_of_a_guessed_type

fn (mut c &Checker) deprecate_old_isreftype_and_sizeof_of_a_guessed_type(is_guessed_type bool, typ v.ast.Type, pos v.token.Pos, label string)

#fn (&Checker) check_import_sym_conflict

fn (c &Checker) check_import_sym_conflict(ident string) bool

#fn (&Checker) get_comptime_var_type

fn (mut c &Checker) get_comptime_var_type(node v.ast.Expr) v.ast.Type

#fn (&Checker) comptime_call

fn (mut c &Checker) comptime_call(mut node &v.ast.ComptimeCall) v.ast.Type

#fn (&Checker) comptime_selector

fn (mut c &Checker) comptime_selector(mut node &v.ast.ComptimeSelector) v.ast.Type

#fn (&Checker) comptime_for

fn (mut c &Checker) comptime_for(node v.ast.ComptimeFor)

#fn (&Checker) eval_comptime_const_expr

fn (mut c &Checker) eval_comptime_const_expr(expr v.ast.Expr, nlevel int) ?v.ast.ComptTimeConstValue

comptime const eval

#fn (&Checker) verify_vweb_params_for_method

fn (mut c &Checker) verify_vweb_params_for_method(node v.ast.Fn) (bool, int, int)

#fn (&Checker) verify_all_vweb_routes

fn (mut c &Checker) verify_all_vweb_routes()

#fn (&Checker) evaluate_once_comptime_if_attribute

fn (mut c &Checker) evaluate_once_comptime_if_attribute(mut node &v.ast.Attr) bool

#fn (&Checker) comptime_if_branch

fn (mut c &Checker) comptime_if_branch(cond v.ast.Expr, pos v.token.Pos) ComptimeBranchSkipState

comptime_if_branch checks the condition of a compile-time if branch. It returns true if that branch's contents should be skipped (targets a different os for example)

#fn (&Checker) get_comptime_selector_type

fn (mut c &Checker) get_comptime_selector_type(node v.ast.ComptimeSelector, default_type v.ast.Type) v.ast.Type

get_comptime_selector_type retrieves the var.$( type when field_name is 'name' otherwise default_type is returned

#fn (&Checker) is_comptime_selector_field_name

fn (mut c &Checker) is_comptime_selector_field_name(node v.ast.SelectorExpr, field_name string) bool

is_comptime_selector_field_name checks if the SelectorExpr is related to $for variable accessing specific field name provided by field_name

#fn (&Checker) is_comptime_selector_type

fn (mut c &Checker) is_comptime_selector_type(node v.ast.SelectorExpr) bool

is_comptime_selector_type checks if the SelectorExpr is related to $for variable accessing .typ field

#fn (&Checker) check_comptime_is_field_selector

fn (mut c &Checker) check_comptime_is_field_selector(node v.ast.SelectorExpr) bool

check_comptime_is_field_selector checks if the SelectorExpr is related to $for variable

#fn (&Checker) check_comptime_is_field_selector_bool

fn (mut c &Checker) check_comptime_is_field_selector_bool(node v.ast.SelectorExpr) bool

check_comptime_is_field_selector_bool checks if the SelectorExpr is related to field.is_* boolean fields

#fn (&Checker) get_comptime_selector_bool_field

fn (mut c &Checker) get_comptime_selector_bool_field(field_name string) bool

get_comptime_selector_bool_field evaluates the bool value for field.is_* fields

#fn (&Checker) array_init

fn (mut c &Checker) array_init(mut node &v.ast.ArrayInit) v.ast.Type

#fn (&Checker) check_array_init_para_type

fn (mut c &Checker) check_array_init_para_type(para string, expr v.ast.Expr, pos v.token.Pos)

#fn (&Checker) ensure_sumtype_array_has_default_value

fn (mut c &Checker) ensure_sumtype_array_has_default_value(node v.ast.ArrayInit)

#fn (&Checker) map_init

fn (mut c &Checker) map_init(mut node &v.ast.MapInit) v.ast.Type

#fn (&Checker) fn_decl

fn (mut c &Checker) fn_decl(mut node &v.ast.FnDecl)

#fn (&Checker) check_same_type_ignoring_pointers

fn (c &Checker) check_same_type_ignoring_pointers(type_a v.ast.Type, type_b v.ast.Type) bool

check_same_type_ignoring_pointers util function to check if the Types are the same, including all corner cases.

FIXME: if the optimization is done after the checker, we can safely remove this util function

#fn (&Checker) anon_fn

fn (mut c &Checker) anon_fn(mut node &v.ast.AnonFn) v.ast.Type

#fn (&Checker) call_expr

fn (mut c &Checker) call_expr(mut node &v.ast.CallExpr) v.ast.Type

#fn (&Checker) builtin_args

fn (mut c &Checker) builtin_args(mut node &v.ast.CallExpr, fn_name string, func v.ast.Fn)

#fn (&Checker) fn_call

fn (mut c &Checker) fn_call(mut node &v.ast.CallExpr, mut continue_check &bool) v.ast.Type

#fn (&Checker) get_comptime_args

fn (mut c &Checker) get_comptime_args(func v.ast.Fn, node_ v.ast.CallExpr, concrete_types []v.ast.Type) map[int]v.ast.Type

#fn (&Checker) resolve_fn_generic_args

fn (mut c &Checker) resolve_fn_generic_args(func v.ast.Fn, mut node &v.ast.CallExpr) []v.ast.Type

#fn (&Checker) method_call

fn (mut c &Checker) method_call(mut node &v.ast.CallExpr) v.ast.Type

#fn (&Checker) go_expr

fn (mut c &Checker) go_expr(mut node &v.ast.GoExpr) v.ast.Type

#fn (&Checker) set_node_expected_arg_types

fn (mut c &Checker) set_node_expected_arg_types(mut node &v.ast.CallExpr, func &v.ast.Fn)

#fn (&Checker) post_process_generic_fns

fn (mut c &Checker) post_process_generic_fns()

#fn (&Checker) check_expected_arg_count

fn (mut c &Checker) check_expected_arg_count(mut node &v.ast.CallExpr, f &v.ast.Fn) !

#fn (&Checker) check_map_and_filter

fn (mut c &Checker) check_map_and_filter(is_map bool, elem_typ v.ast.Type, node v.ast.CallExpr)

#fn (&Checker) map_builtin_method_call

fn (mut c &Checker) map_builtin_method_call(mut node &v.ast.CallExpr, left_type v.ast.Type, left_sym v.ast.TypeSymbol) v.ast.Type

#fn (&Checker) array_builtin_method_call

fn (mut c &Checker) array_builtin_method_call(mut node &v.ast.CallExpr, left_type v.ast.Type, left_sym v.ast.TypeSymbol) v.ast.Type

#fn (&Checker) for_c_stmt

fn (mut c &Checker) for_c_stmt(node v.ast.ForCStmt)

#fn (&Checker) for_in_stmt

fn (mut c &Checker) for_in_stmt(mut node &v.ast.ForInStmt)

#fn (&Checker) for_stmt

fn (mut c &Checker) for_stmt(mut node &v.ast.ForStmt)

#fn (&Checker) check_compatible_types

fn (mut c &Checker) check_compatible_types(left_type v.ast.Type, right v.ast.TypeNode) ComptimeBranchSkipState

#fn (&Checker) if_expr

fn (mut c &Checker) if_expr(mut node &v.ast.IfExpr) v.ast.Type

#fn (&Checker) smartcast_if_conds

fn (mut c &Checker) smartcast_if_conds(node v.ast.Expr, mut scope &v.ast.Scope)

#fn (&Checker) check_non_expr_branch_last_stmt

fn (mut c &Checker) check_non_expr_branch_last_stmt(stmts []v.ast.Stmt)

#fn (&Checker) infix_expr

fn (mut c &Checker) infix_expr(mut node &v.ast.InfixExpr) v.ast.Type

#fn (&Checker) check_div_mod_by_zero

fn (mut c &Checker) check_div_mod_by_zero(expr v.ast.Expr, op_kind v.token.Kind)

#fn (&Checker) check_like_operator

fn (mut c &Checker) check_like_operator(node &v.ast.InfixExpr) v.ast.Type

#fn (&Checker) invalid_operator_error

fn (mut c &Checker) invalid_operator_error(op v.token.Kind, left_type v.ast.Type, right_type v.ast.Type, pos v.token.Pos)

#fn (&Checker) interface_decl

fn (mut c &Checker) interface_decl(mut node &v.ast.InterfaceDecl)

#fn (&Checker) resolve_generic_interface

fn (mut c &Checker) resolve_generic_interface(typ v.ast.Type, interface_type v.ast.Type, pos v.token.Pos) v.ast.Type

#fn (&Checker) match_expr

fn (mut c &Checker) match_expr(mut node &v.ast.MatchExpr) v.ast.Type

#fn (&Checker) check_match_branch_last_stmt

fn (mut c &Checker) check_match_branch_last_stmt(last_stmt v.ast.ExprStmt, ret_type v.ast.Type, expr_type v.ast.Type)

#fn (&Checker) get_comptime_number_value

fn (mut c &Checker) get_comptime_number_value(mut expr &v.ast.Expr) ?i64

#fn (&Checker) match_exprs

fn (mut c &Checker) match_exprs(mut node &v.ast.MatchExpr, cond_type_sym v.ast.TypeSymbol)

#fn (&Checker) sql_expr

fn (mut c &Checker) sql_expr(mut node &v.ast.SqlExpr) v.ast.Type

#fn (&Checker) sql_stmt

fn (mut c &Checker) sql_stmt(mut node &v.ast.SqlStmt) v.ast.Type

#fn (&Checker) sql_stmt_line

fn (mut c &Checker) sql_stmt_line(mut node &v.ast.SqlStmtLine) v.ast.Type

#fn (&Checker) check_orm_struct_field_attributes

fn (mut c &Checker) check_orm_struct_field_attributes(field v.ast.StructField)

#fn (&Checker) fetch_and_verify_orm_fields

fn (mut c &Checker) fetch_and_verify_orm_fields(info v.ast.Struct, pos v.token.Pos, table_name string) []v.ast.StructField

#fn (&Checker) check_sql_value_expr_is_comptime_with_natural_number_or_expr_with_int_type

fn (mut c &Checker) check_sql_value_expr_is_comptime_with_natural_number_or_expr_with_int_type(mut expr &v.ast.Expr, sql_keyword string)

check_sql_value_expr_is_comptime_with_natural_number_or_expr_with_int_type checks that an expression is compile-time and contains an integer greater than or equal to zero or it is a runtime expression with an integer type.

#fn (&Checker) check_sql_expr_type_is_int

fn (mut c &Checker) check_sql_expr_type_is_int(expr &v.ast.Expr, sql_keyword string)

#fn (&Checker) orm_error

fn (mut c &Checker) orm_error(message string, pos v.token.Pos)

#fn (&Checker) check_expr_has_no_fn_calls_with_non_orm_return_type

fn (mut c &Checker) check_expr_has_no_fn_calls_with_non_orm_return_type(expr &v.ast.Expr)

check_expr_has_no_fn_calls_with_non_orm_return_type checks that an expression has no function calls that return complex types which can't be transformed into SQL.

#fn (&Checker) check_where_expr_has_no_pointless_exprs

fn (mut c &Checker) check_where_expr_has_no_pointless_exprs(table_type_symbol &v.ast.TypeSymbol, field_names []string, expr &v.ast.Expr)

check_where_expr_has_no_pointless_exprs checks that an expression has no pointless expressions which don't affect the result. For example, where 3 is pointless.

Also, it checks that the left side of the infix expression is always the structure field.

#fn (&Checker) fn_return_type_flag_to_string

fn (_ &Checker) fn_return_type_flag_to_string(typ v.ast.Type) string

#fn (&Checker) check_orm_or_expr

fn (mut c &Checker) check_orm_or_expr(expr ORMExpr)

#fn (&Checker) postfix_expr

fn (mut c &Checker) postfix_expr(mut node &v.ast.PostfixExpr) v.ast.Type

#fn (&Checker) error_type_name

fn (mut c &Checker) error_type_name(exp_type v.ast.Type) string

error_type_name returns a proper type name reference for error messages ? => Option type ! => Result type others => type name

#fn (&Checker) return_stmt

fn (mut c &Checker) return_stmt(mut node &v.ast.Return)

TODO: non deferred

#fn (&Checker) find_unreachable_statements_after_noreturn_calls

fn (mut c &Checker) find_unreachable_statements_after_noreturn_calls(stmts []v.ast.Stmt)

#fn (&Checker) check_noreturn_fn_decl

fn (mut c &Checker) check_noreturn_fn_decl(mut node &v.ast.FnDecl)

#fn (&Checker) get_default_fmt

fn (mut c &Checker) get_default_fmt(ftyp v.ast.Type, typ v.ast.Type) u8

#fn (&Checker) string_inter_lit

fn (mut c &Checker) string_inter_lit(mut node &v.ast.StringInterLiteral) v.ast.Type

#fn (&Checker) string_lit

fn (mut c &Checker) string_lit(mut node &v.ast.StringLiteral) v.ast.Type

unicode character literals are limited to a maximum value of 0x10ffff

#fn (&Checker) int_lit

fn (mut c &Checker) int_lit(mut node &v.ast.IntegerLiteral) v.ast.Type

#fn (&Checker) check_num_literal

fn (mut c &Checker) check_num_literal(lohi LoHiLimit, is_neg bool, lit string) !

#fn (&Checker) num_lit_overflow_error

fn (mut c &Checker) num_lit_overflow_error(node &v.ast.IntegerLiteral)

#fn (&Checker) struct_decl

fn (mut c &Checker) struct_decl(mut node &v.ast.StructDecl)

#fn (&Checker) struct_init

fn (mut c &Checker) struct_init(mut node &v.ast.StructInit, is_field_zero_struct_init bool, mut inited_fields &[]string) v.ast.Type

#fn (&Checker) check_ref_fields_initialized

fn (mut c &Checker) check_ref_fields_initialized(struct_sym &v.ast.TypeSymbol, mut checked_types &[]v.ast.Type, linked_name string, node &v.ast.StructInit)

Recursively check whether the struct type field is initialized


This section is empty.


This section is empty.