From 14db4a38a9c712e463975a03c6bab781c5101c81 Mon Sep 17 00:00:00 2001 From: Turiiya <34311583+tobealive@users.noreply.github.com> Date: Mon, 8 May 2023 13:38:09 +0200 Subject: [PATCH] revert "parser: disallow module name as expression name" This reverts commit 3248962111fd28c11ae2366de5d55030a060831e. --- vlib/v/parser/assign.v | 4 ---- vlib/v/parser/fn.v | 6 ------ vlib/v/parser/parser.v | 3 --- 3 files changed, 13 deletions(-) diff --git a/vlib/v/parser/assign.v b/vlib/v/parser/assign.v index 5174639ae1..99a2c226b8 100644 --- a/vlib/v/parser/assign.v +++ b/vlib/v/parser/assign.v @@ -202,10 +202,6 @@ fn (mut p Parser) partial_assign_stmt(left []ast.Expr, left_comments []ast.Comme match mut lx { ast.Ident { if op == .decl_assign { - if p.mod == lx.name { - return p.error_with_pos('expression names cannot match module name', - lx.pos) - } if p.scope.known_var(lx.name) { return p.error_with_pos('redefinition of `${lx.name}`', lx.pos) } diff --git a/vlib/v/parser/fn.v b/vlib/v/parser/fn.v index 1ebd822a5f..44fb613c99 100644 --- a/vlib/v/parser/fn.v +++ b/vlib/v/parser/fn.v @@ -373,12 +373,6 @@ fn (mut p Parser) fn_decl() ast.FnDecl { params << args2 if !are_args_type_only { for k, param in params { - if p.mod == param.name { - p.error_with_pos('parameter names cannot match module name', param.pos) - return ast.FnDecl{ - scope: 0 - } - } if p.scope.known_var(param.name) { p.error_with_pos('redefinition of parameter `${param.name}`', param.pos) return ast.FnDecl{ diff --git a/vlib/v/parser/parser.v b/vlib/v/parser/parser.v index 63f2466c51..246d7230b6 100644 --- a/vlib/v/parser/parser.v +++ b/vlib/v/parser/parser.v @@ -3677,9 +3677,6 @@ fn (mut p Parser) const_decl() ast.ConstDecl { if p.tok.kind == .decl_assign { p.error_with_pos('cannot use `:=` to declare a const, use `=` instead', p.tok.pos()) } - if p.mod == name { - p.error_with_pos('const names cannot match module name', pos) - } p.check(.assign) end_comments << p.eat_comments() if p.tok.kind == .key_fn {