From 8b5573a6f31b22e98e69a821a68a4cbe1d87b521 Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Thu, 23 Apr 2020 13:14:54 +0300 Subject: [PATCH] errors: use more distinct and detailed name redefinition messages --- vlib/v/parser/fn.v | 2 +- vlib/v/parser/for.v | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/vlib/v/parser/fn.v b/vlib/v/parser/fn.v index 9639f52790..9f735bbced 100644 --- a/vlib/v/parser/fn.v +++ b/vlib/v/parser/fn.v @@ -191,7 +191,7 @@ fn (mut p Parser) fn_decl() ast.FnDecl { name = p.prepend_mod(name) } if _ := p.table.find_fn(name) { - p.error('redefinition of `$name`') + p.error('redefinition of function `$name`') } p.table.register_fn(table.Fn{ name: name diff --git a/vlib/v/parser/for.v b/vlib/v/parser/for.v index 3d6e8b3198..5ca4e2815b 100644 --- a/vlib/v/parser/for.v +++ b/vlib/v/parser/for.v @@ -74,21 +74,21 @@ fn (mut p Parser) for_stmt() ast.Stmt { key_var_name = val_var_name val_var_name = p.check_name() if p.scope.known_var(key_var_name) { - p.error('redefinition of `$key_var_name`') + p.error('redefinition of key iteration variable `$key_var_name`') } if p.scope.known_var(val_var_name) { - p.error('redefinition of `$val_var_name`') + p.error('redefinition of value iteration variable `$val_var_name`') } p.scope.register(key_var_name, ast.Var{ name: key_var_name typ: table.int_type }) } else if p.scope.known_var(val_var_name) { - p.error('redefinition of `$val_var_name`') + p.error('redefinition of value iteration variable `$val_var_name`') } p.check(.key_in) if p.tok.kind == .name && p.tok.lit in [key_var_name, val_var_name] { - p.error('redefinition of `$p.tok.lit`') + p.error('in a `for x in array` loop, the key or value iteration variable `$p.tok.lit` can not be the same as the array variable') } // arr_expr cond := p.expr(0)