diff --git a/vlib/v/checker/checker.v b/vlib/v/checker/checker.v index eecc17a263..5d47ad7656 100644 --- a/vlib/v/checker/checker.v +++ b/vlib/v/checker/checker.v @@ -1891,13 +1891,6 @@ pub fn (mut c Checker) check_or_expr(node ast.OrExpr, ret_type ast.Type, expr_re } } -fn is_noreturn_callexpr(expr ast.Expr) bool { - if expr is ast.CallExpr { - return expr.is_noreturn - } - return false -} - pub fn (mut c Checker) selector_expr(mut node ast.SelectorExpr) ast.Type { prevent_sum_type_unwrapping_once := c.prevent_sum_type_unwrapping_once c.prevent_sum_type_unwrapping_once = false @@ -2075,7 +2068,6 @@ pub fn (mut c Checker) selector_expr(mut node ast.SelectorExpr) ast.Type { return ast.void_type } -// TODO: non deferred pub fn (mut c Checker) const_decl(mut node ast.ConstDecl) { if node.fields.len == 0 { c.warn('const block must have at least 1 declaration', node.pos) @@ -2177,30 +2169,6 @@ pub fn (mut c Checker) enum_decl(mut node ast.EnumDecl) { } } -fn scope_register_it(mut s ast.Scope, pos token.Position, typ ast.Type) { - s.register(ast.Var{ - name: 'it' - pos: pos - typ: typ - is_used: true - }) -} - -fn scope_register_a_b(mut s ast.Scope, pos token.Position, typ ast.Type) { - s.register(ast.Var{ - name: 'a' - pos: pos - typ: typ.ref() - is_used: true - }) - s.register(ast.Var{ - name: 'b' - pos: pos - typ: typ.ref() - is_used: true - }) -} - fn (mut c Checker) check_array_init_para_type(para string, expr ast.Expr, pos token.Position) { sym := c.table.get_type_symbol(c.expr(expr)) if sym.kind !in [.int, .int_literal] { diff --git a/vlib/v/checker/comptime.v b/vlib/v/checker/comptime.v index 790ff0912f..02d24cb76e 100644 --- a/vlib/v/checker/comptime.v +++ b/vlib/v/checker/comptime.v @@ -800,3 +800,27 @@ fn (mut c Checker) array_builtin_method_call(mut node ast.CallExpr, left_type as } return node.return_type } + +fn scope_register_it(mut s ast.Scope, pos token.Position, typ ast.Type) { + s.register(ast.Var{ + name: 'it' + pos: pos + typ: typ + is_used: true + }) +} + +fn scope_register_a_b(mut s ast.Scope, pos token.Position, typ ast.Type) { + s.register(ast.Var{ + name: 'a' + pos: pos + typ: typ.ref() + is_used: true + }) + s.register(ast.Var{ + name: 'b' + pos: pos + typ: typ.ref() + is_used: true + }) +} diff --git a/vlib/v/checker/return.v b/vlib/v/checker/return.v index 4c10f49bac..d593605c11 100644 --- a/vlib/v/checker/return.v +++ b/vlib/v/checker/return.v @@ -5,6 +5,7 @@ module checker import v.ast import v.pref +// TODO: non deferred pub fn (mut c Checker) return_stmt(mut node ast.Return) { c.expected_type = c.table.cur_fn.return_type mut expected_type := c.unwrap_generic(c.expected_type) @@ -309,3 +310,10 @@ fn uses_return_stmt(stmts []ast.Stmt) bool { } return false } + +fn is_noreturn_callexpr(expr ast.Expr) bool { + if expr is ast.CallExpr { + return expr.is_noreturn + } + return false +}