From 4b0ded04758638aeaea18d2884683ae0c0288cb4 Mon Sep 17 00:00:00 2001 From: Nick Treleaven Date: Wed, 15 Jul 2020 18:59:39 +0100 Subject: [PATCH] checker: Warn instead of error for pointer arithmetic (#5840) --- vlib/v/checker/checker.v | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/vlib/v/checker/checker.v b/vlib/v/checker/checker.v index d4cbbbf18b..b249cbf094 100644 --- a/vlib/v/checker/checker.v +++ b/vlib/v/checker/checker.v @@ -480,7 +480,7 @@ pub fn (mut c Checker) infix_expr(mut infix_expr ast.InfixExpr) table.Type { right_pos := infix_expr.right.position() if (left_type.is_ptr() || left.is_pointer()) && infix_expr.op in [.plus, .minus] && !c.inside_unsafe { - c.error('pointer arithmetic is only allowed in `unsafe` blocks', left_pos) + c.warn('pointer arithmetic is only allowed in `unsafe` blocks', left_pos) } mut return_type := left_type // Single side check @@ -1632,7 +1632,7 @@ pub fn (mut c Checker) assign_stmt(mut assign_stmt ast.AssignStmt) { right_sym := c.table.get_type_symbol(right_type_unwrapped) if (left_type.is_ptr() || left_sym.is_pointer()) && assign_stmt.op !in [.assign, .decl_assign] && !c.inside_unsafe { - c.error('pointer arithmetic is only allowed in `unsafe` blocks', assign_stmt.pos) + c.warn('pointer arithmetic is only allowed in `unsafe` blocks', assign_stmt.pos) } // Single side check match assign_stmt.op { @@ -2876,7 +2876,7 @@ pub fn (mut c Checker) postfix_expr(mut node ast.PostfixExpr) table.Type { node.auto_locked, _ = c.fail_if_immutable(node.expr) } if (typ.is_ptr() || typ_sym.is_pointer()) && !c.inside_unsafe { - c.error('pointer arithmetic is only allowed in `unsafe` blocks', node.pos) + c.warn('pointer arithmetic is only allowed in `unsafe` blocks', node.pos) } return typ }