From 14e1b963f2460edb9d2f8bd432d3fcbbe3f4703c Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Tue, 14 Apr 2020 20:39:55 +0200 Subject: [PATCH] parser: do not allow variable names with capital letters --- vlib/v/parser/parser.v | 3 +++ 1 file changed, 3 insertions(+) diff --git a/vlib/v/parser/parser.v b/vlib/v/parser/parser.v index f74a4819dd..c4c9d2f0e1 100644 --- a/vlib/v/parser/parser.v +++ b/vlib/v/parser/parser.v @@ -1784,6 +1784,9 @@ fn (p mut Parser) assign_stmt() ast.Stmt { exprs := p.parse_assign_rhs() is_decl := op == .decl_assign for i, ident in idents { + if op == .decl_assign && scanner.contains_capital(ident.name) { + p.error('variable names cannot contain uppercase letters, use snake_case instead') + } known_var := p.scope.known_var(ident.name) if !is_decl && !known_var { p.error('unknown variable `$ident.name`')